Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed MLTableAlert Files/Images/MLTableAlertBackground.png
Binary file not shown.
Binary file not shown.
Binary file removed MLTableAlert Files/Images/MLTableAlertButton.png
Binary file not shown.
Binary file removed MLTableAlert Files/Images/MLTableAlertButton@2x.png
Binary file not shown.
Binary file removed MLTableAlert Files/Images/MLTableAlertButtonPressed.png
Binary file not shown.
Binary file not shown.
Binary file removed MLTableAlert Files/Images/MLTableAlertShadowMask.png
Binary file not shown.
Binary file removed MLTableAlert Files/Images/MLTableAlertShadowMask@2x.png
Binary file not shown.
55 changes: 24 additions & 31 deletions MLTableAlert Files/MLTableAlert.m
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
#define kVerticalInset 8.0
#define kMinAlertHeight 264.0
#define kCancelButtonHeight 44.0
#define kCancelButtonMargin 5.0
#define kTitleLabelMargin 12.0
#define kCancelButtonMargin 0
#define kTitleLabelMargin 0


// Since orientation is managed by view controllers,
Expand Down Expand Up @@ -200,48 +200,44 @@ -(void)show

// alert view creation
self.alertBg = [[UIView alloc] initWithFrame:CGRectZero];
self.alertBg.backgroundColor = [UIColor whiteColor];
self.alertBg.layer.cornerRadius = 3.0;
[self addSubview:self.alertBg];

// setting alert background image
UIImageView *alertBgImage = [[UIImageView alloc] initWithImage:[[UIImage imageNamed:@"MLTableAlertBackground.png"] stretchableImageWithLeftCapWidth:15 topCapHeight:30]];
[self.alertBg addSubview:alertBgImage];

// alert title creation
self.titleLabel = [[UILabel alloc] initWithFrame:CGRectZero];
self.titleLabel.backgroundColor = [UIColor clearColor];
self.titleLabel.textColor = [UIColor whiteColor];
self.titleLabel.shadowColor = [[UIColor blackColor] colorWithAlphaComponent:0.75];
self.titleLabel.shadowOffset = CGSizeMake(0, -1);
self.titleLabel.backgroundColor = [UIColor whiteColor];
self.titleLabel.textColor = [UIColor blackColor];
self.titleLabel.font = [UIFont boldSystemFontOfSize:18.0];
self.titleLabel.frame = CGRectMake(kLateralInset, 15, kTableAlertWidth - kLateralInset * 2, 22);
self.titleLabel.frame = CGRectMake(kLateralInset, 10, kTableAlertWidth - kLateralInset * 2, 30);
self.titleLabel.text = self.title;
self.titleLabel.textAlignment = NSTextAlignmentCenter;
[self.alertBg addSubview:self.titleLabel];

// table view creation
self.table = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
self.table.frame = CGRectMake(kLateralInset, self.titleLabel.frame.origin.y + self.titleLabel.frame.size.height + kTitleLabelMargin, kTableAlertWidth - kLateralInset * 2, (self.height - kVerticalInset * 2) - self.titleLabel.frame.origin.y - self.titleLabel.frame.size.height - kTitleLabelMargin - (kCancelButtonMargin + kCancelButtonHeight)*(self.cancelButtonTitle ? 1 : 0));
self.table.layer.cornerRadius = 6.0;
self.table.backgroundColor = [UIColor whiteColor];
self.table.layer.masksToBounds = YES;
self.table.delegate = self;
self.table.dataSource = self;
self.table.separatorStyle = UITableViewCellSeparatorStyleNone;
self.table.backgroundView = [[UIView alloc] init];

[self.alertBg addSubview:self.table];

// setting white-to-gray gradient as table view's background
CAGradientLayer *tableGradient = [CAGradientLayer layer];
tableGradient.frame = CGRectMake(0, 0, self.table.frame.size.width, self.table.frame.size.height);
tableGradient.colors = [NSArray arrayWithObjects:(id)[[UIColor colorWithRed:240.0/255.0 green:240.0/255.0 blue:240.0/255.0 alpha:1.0] CGColor], (id)[[UIColor colorWithRed:174.0/255.0 green:174.0/255.0 blue:174.0/255.0 alpha:1.0] CGColor], nil];
[self.table.backgroundView.layer insertSublayer:tableGradient atIndex:0];


CGSize mainViewSize = self.alertBg.bounds.size;
CGFloat borderWidth = 1;
UIColor *borderColor = [UIColor colorWithRed:37.0/255 green:38.0/255 blue:39.0/255 alpha:0.3];
UIView *topView = [[UIView alloc] initWithFrame:CGRectMake(0.0, self.table.frame.origin.y + self.table.frame.size.height, mainViewSize.width, borderWidth)];
topView.opaque = YES;
topView.backgroundColor = borderColor;
topView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin;
[self.alertBg addSubview:topView];

// adding inner shadow mask on table view
UIImageView *maskShadow = [[UIImageView alloc] initWithImage:[[UIImage imageNamed:@"MLTableAlertShadowMask.png"] stretchableImageWithLeftCapWidth:6 topCapHeight:7]];
maskShadow.userInteractionEnabled = NO;
maskShadow.layer.masksToBounds = YES;
maskShadow.layer.cornerRadius = 5.0;
maskShadow.frame = self.table.frame;
[self.alertBg addSubview:maskShadow];

// cancel button creation
if (self.cancelButtonTitle)
Expand All @@ -250,22 +246,19 @@ -(void)show
self.cancelButton.frame = CGRectMake(kLateralInset, self.table.frame.origin.y + self.table.frame.size.height + kCancelButtonMargin, kTableAlertWidth - kLateralInset * 2, kCancelButtonHeight);
self.cancelButton.titleLabel.textAlignment = NSTextAlignmentCenter;
self.cancelButton.titleLabel.font = [UIFont boldSystemFontOfSize:17.0];
self.cancelButton.titleLabel.shadowOffset = CGSizeMake(0, -1);
self.cancelButton.titleLabel.shadowColor = [[UIColor blackColor] colorWithAlphaComponent:0.75];
[self.cancelButton setTitle:self.cancelButtonTitle forState:UIControlStateNormal];
[self.cancelButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[self.cancelButton setBackgroundColor:[UIColor clearColor]];
[self.cancelButton setBackgroundImage:[[UIImage imageNamed:@"MLTableAlertButton.png"] stretchableImageWithLeftCapWidth:5 topCapHeight:0] forState:UIControlStateNormal];
[self.cancelButton setBackgroundImage:[[UIImage imageNamed:@"MLTableAlertButtonPressed.png"] stretchableImageWithLeftCapWidth:5 topCapHeight:0] forState:UIControlStateHighlighted];
[self.cancelButton setTitleColor:[UIColor colorWithRed:0.0 green:122.0/255.0 blue:1.0 alpha:1.0] forState:UIControlStateNormal];
[self.cancelButton setTitleColor:[UIColor blackColor] forState:UIControlStateSelected];

self.cancelButton.opaque = NO;
self.cancelButton.layer.cornerRadius = 5.0;

[self.cancelButton addTarget:self action:@selector(dismissTableAlert) forControlEvents:UIControlEventTouchUpInside];
[self.alertBg addSubview:self.cancelButton];
}

// setting alert and alert background image frames
self.alertBg.frame = CGRectMake((self.frame.size.width - kTableAlertWidth) / 2, (self.frame.size.height - self.height) / 2, kTableAlertWidth, self.height - kVerticalInset * 2);
alertBgImage.frame = CGRectMake(0.0, 0.0, kTableAlertWidth, self.height);


// the alert will be the first responder so any other controls,
// like the keyboard, will be dismissed before the alert
Expand Down
40 changes: 0 additions & 40 deletions MLTableAlertDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@
objects = {

/* Begin PBXBuildFile section */
95803BA816826C8800F0FEB0 /* MLTableAlertBackground.png in Resources */ = {isa = PBXBuildFile; fileRef = 95803B9E16826C8800F0FEB0 /* MLTableAlertBackground.png */; };
95803BA916826C8800F0FEB0 /* MLTableAlertBackground@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 95803B9F16826C8800F0FEB0 /* MLTableAlertBackground@2x.png */; };
95803BAA16826C8800F0FEB0 /* MLTableAlertButton.png in Resources */ = {isa = PBXBuildFile; fileRef = 95803BA016826C8800F0FEB0 /* MLTableAlertButton.png */; };
95803BAB16826C8800F0FEB0 /* MLTableAlertButton@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 95803BA116826C8800F0FEB0 /* MLTableAlertButton@2x.png */; };
95803BAC16826C8800F0FEB0 /* MLTableAlertButtonPressed.png in Resources */ = {isa = PBXBuildFile; fileRef = 95803BA216826C8800F0FEB0 /* MLTableAlertButtonPressed.png */; };
95803BAD16826C8800F0FEB0 /* MLTableAlertButtonPressed@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 95803BA316826C8800F0FEB0 /* MLTableAlertButtonPressed@2x.png */; };
95803BAE16826C8800F0FEB0 /* MLTableAlertShadowMask.png in Resources */ = {isa = PBXBuildFile; fileRef = 95803BA416826C8800F0FEB0 /* MLTableAlertShadowMask.png */; };
95803BAF16826C8800F0FEB0 /* MLTableAlertShadowMask@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 95803BA516826C8800F0FEB0 /* MLTableAlertShadowMask@2x.png */; };
95803BB016826C8800F0FEB0 /* MLTableAlert.m in Sources */ = {isa = PBXBuildFile; fileRef = 95803BA716826C8800F0FEB0 /* MLTableAlert.m */; };
95803BC016826CA000F0FEB0 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 95803BB316826CA000F0FEB0 /* AppDelegate.m */; };
95803BC116826CA000F0FEB0 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 95803BB416826CA000F0FEB0 /* Default-568h@2x.png */; };
Expand All @@ -31,14 +23,6 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
95803B9E16826C8800F0FEB0 /* MLTableAlertBackground.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = MLTableAlertBackground.png; sourceTree = "<group>"; };
95803B9F16826C8800F0FEB0 /* MLTableAlertBackground@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "MLTableAlertBackground@2x.png"; sourceTree = "<group>"; };
95803BA016826C8800F0FEB0 /* MLTableAlertButton.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = MLTableAlertButton.png; sourceTree = "<group>"; };
95803BA116826C8800F0FEB0 /* MLTableAlertButton@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "MLTableAlertButton@2x.png"; sourceTree = "<group>"; };
95803BA216826C8800F0FEB0 /* MLTableAlertButtonPressed.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = MLTableAlertButtonPressed.png; sourceTree = "<group>"; };
95803BA316826C8800F0FEB0 /* MLTableAlertButtonPressed@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "MLTableAlertButtonPressed@2x.png"; sourceTree = "<group>"; };
95803BA416826C8800F0FEB0 /* MLTableAlertShadowMask.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = MLTableAlertShadowMask.png; sourceTree = "<group>"; };
95803BA516826C8800F0FEB0 /* MLTableAlertShadowMask@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "MLTableAlertShadowMask@2x.png"; sourceTree = "<group>"; };
95803BA616826C8800F0FEB0 /* MLTableAlert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MLTableAlert.h; sourceTree = "<group>"; };
95803BA716826C8800F0FEB0 /* MLTableAlert.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MLTableAlert.m; sourceTree = "<group>"; };
95803BB216826CA000F0FEB0 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -78,28 +62,12 @@
95803B9C16826C8800F0FEB0 /* MLTableAlert Files */ = {
isa = PBXGroup;
children = (
95803B9D16826C8800F0FEB0 /* Images */,
95803BA616826C8800F0FEB0 /* MLTableAlert.h */,
95803BA716826C8800F0FEB0 /* MLTableAlert.m */,
);
path = "MLTableAlert Files";
sourceTree = "<group>";
};
95803B9D16826C8800F0FEB0 /* Images */ = {
isa = PBXGroup;
children = (
95803B9E16826C8800F0FEB0 /* MLTableAlertBackground.png */,
95803B9F16826C8800F0FEB0 /* MLTableAlertBackground@2x.png */,
95803BA016826C8800F0FEB0 /* MLTableAlertButton.png */,
95803BA116826C8800F0FEB0 /* MLTableAlertButton@2x.png */,
95803BA216826C8800F0FEB0 /* MLTableAlertButtonPressed.png */,
95803BA316826C8800F0FEB0 /* MLTableAlertButtonPressed@2x.png */,
95803BA416826C8800F0FEB0 /* MLTableAlertShadowMask.png */,
95803BA516826C8800F0FEB0 /* MLTableAlertShadowMask@2x.png */,
);
path = Images;
sourceTree = "<group>";
};
95803BB116826CA000F0FEB0 /* MLTableAlertDemo */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -207,14 +175,6 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
95803BA816826C8800F0FEB0 /* MLTableAlertBackground.png in Resources */,
95803BA916826C8800F0FEB0 /* MLTableAlertBackground@2x.png in Resources */,
95803BAA16826C8800F0FEB0 /* MLTableAlertButton.png in Resources */,
95803BAB16826C8800F0FEB0 /* MLTableAlertButton@2x.png in Resources */,
95803BAC16826C8800F0FEB0 /* MLTableAlertButtonPressed.png in Resources */,
95803BAD16826C8800F0FEB0 /* MLTableAlertButtonPressed@2x.png in Resources */,
95803BAE16826C8800F0FEB0 /* MLTableAlertShadowMask.png in Resources */,
95803BAF16826C8800F0FEB0 /* MLTableAlertShadowMask@2x.png in Resources */,
95803BC116826CA000F0FEB0 /* Default-568h@2x.png in Resources */,
95803BC216826CA000F0FEB0 /* Default.png in Resources */,
95803BC316826CA000F0FEB0 /* Default@2x.png in Resources */,
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Here are some features:

This is how the alert looks like:

![MLTableAlert](http://www.matthewlabs.com/resources/external/MLTableAlertGitHubSmall.png "MLTableAlert")
![MLTableAlert](http://www.webninjamobile.com/repo/MLTableAlert.png "MLTableAlert")

Use MLTableAlert in your projects
---
Expand Down