diff --git a/MLTableAlert Files/Images/MLTableAlertBackground.png b/MLTableAlert Files/Images/MLTableAlertBackground.png deleted file mode 100644 index 57d8cc9..0000000 Binary files a/MLTableAlert Files/Images/MLTableAlertBackground.png and /dev/null differ diff --git a/MLTableAlert Files/Images/MLTableAlertBackground@2x.png b/MLTableAlert Files/Images/MLTableAlertBackground@2x.png deleted file mode 100644 index c2b7c66..0000000 Binary files a/MLTableAlert Files/Images/MLTableAlertBackground@2x.png and /dev/null differ diff --git a/MLTableAlert Files/Images/MLTableAlertButton.png b/MLTableAlert Files/Images/MLTableAlertButton.png deleted file mode 100644 index 1cccd89..0000000 Binary files a/MLTableAlert Files/Images/MLTableAlertButton.png and /dev/null differ diff --git a/MLTableAlert Files/Images/MLTableAlertButton@2x.png b/MLTableAlert Files/Images/MLTableAlertButton@2x.png deleted file mode 100644 index a1d3d2a..0000000 Binary files a/MLTableAlert Files/Images/MLTableAlertButton@2x.png and /dev/null differ diff --git a/MLTableAlert Files/Images/MLTableAlertButtonPressed.png b/MLTableAlert Files/Images/MLTableAlertButtonPressed.png deleted file mode 100644 index 5094083..0000000 Binary files a/MLTableAlert Files/Images/MLTableAlertButtonPressed.png and /dev/null differ diff --git a/MLTableAlert Files/Images/MLTableAlertButtonPressed@2x.png b/MLTableAlert Files/Images/MLTableAlertButtonPressed@2x.png deleted file mode 100644 index 8ae06dc..0000000 Binary files a/MLTableAlert Files/Images/MLTableAlertButtonPressed@2x.png and /dev/null differ diff --git a/MLTableAlert Files/Images/MLTableAlertShadowMask.png b/MLTableAlert Files/Images/MLTableAlertShadowMask.png deleted file mode 100644 index d0e3c5d..0000000 Binary files a/MLTableAlert Files/Images/MLTableAlertShadowMask.png and /dev/null differ diff --git a/MLTableAlert Files/Images/MLTableAlertShadowMask@2x.png b/MLTableAlert Files/Images/MLTableAlertShadowMask@2x.png deleted file mode 100644 index ca2d8ec..0000000 Binary files a/MLTableAlert Files/Images/MLTableAlertShadowMask@2x.png and /dev/null differ diff --git a/MLTableAlert Files/MLTableAlert.m b/MLTableAlert Files/MLTableAlert.m old mode 100644 new mode 100755 index 0460272..25c28f2 --- a/MLTableAlert Files/MLTableAlert.m +++ b/MLTableAlert Files/MLTableAlert.m @@ -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, @@ -200,20 +200,18 @@ -(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]; @@ -221,27 +219,25 @@ -(void)show // 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) @@ -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 diff --git a/MLTableAlertDemo.xcodeproj/project.pbxproj b/MLTableAlertDemo.xcodeproj/project.pbxproj index b6eaf86..6689fb6 100644 --- a/MLTableAlertDemo.xcodeproj/project.pbxproj +++ b/MLTableAlertDemo.xcodeproj/project.pbxproj @@ -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 */; }; @@ -31,14 +23,6 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ - 95803B9E16826C8800F0FEB0 /* MLTableAlertBackground.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = MLTableAlertBackground.png; sourceTree = ""; }; - 95803B9F16826C8800F0FEB0 /* MLTableAlertBackground@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "MLTableAlertBackground@2x.png"; sourceTree = ""; }; - 95803BA016826C8800F0FEB0 /* MLTableAlertButton.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = MLTableAlertButton.png; sourceTree = ""; }; - 95803BA116826C8800F0FEB0 /* MLTableAlertButton@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "MLTableAlertButton@2x.png"; sourceTree = ""; }; - 95803BA216826C8800F0FEB0 /* MLTableAlertButtonPressed.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = MLTableAlertButtonPressed.png; sourceTree = ""; }; - 95803BA316826C8800F0FEB0 /* MLTableAlertButtonPressed@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "MLTableAlertButtonPressed@2x.png"; sourceTree = ""; }; - 95803BA416826C8800F0FEB0 /* MLTableAlertShadowMask.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = MLTableAlertShadowMask.png; sourceTree = ""; }; - 95803BA516826C8800F0FEB0 /* MLTableAlertShadowMask@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "MLTableAlertShadowMask@2x.png"; sourceTree = ""; }; 95803BA616826C8800F0FEB0 /* MLTableAlert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MLTableAlert.h; sourceTree = ""; }; 95803BA716826C8800F0FEB0 /* MLTableAlert.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MLTableAlert.m; sourceTree = ""; }; 95803BB216826CA000F0FEB0 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; @@ -78,28 +62,12 @@ 95803B9C16826C8800F0FEB0 /* MLTableAlert Files */ = { isa = PBXGroup; children = ( - 95803B9D16826C8800F0FEB0 /* Images */, 95803BA616826C8800F0FEB0 /* MLTableAlert.h */, 95803BA716826C8800F0FEB0 /* MLTableAlert.m */, ); path = "MLTableAlert Files"; sourceTree = ""; }; - 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 = ""; - }; 95803BB116826CA000F0FEB0 /* MLTableAlertDemo */ = { isa = PBXGroup; children = ( @@ -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 */, diff --git a/README.md b/README.md index 8daf17e..a8db4f6 100644 --- a/README.md +++ b/README.md @@ -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 ---