From f419d59e9241f0767150346ea1c0bc422de092e4 Mon Sep 17 00:00:00 2001 From: Benny Liu Date: Tue, 8 Jul 2014 11:52:57 +0800 Subject: [PATCH 1/5] add custom button support --- TestActionSheet/DoActionSheet/DoActionSheet.m | 39 ++++++++++--------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/TestActionSheet/DoActionSheet/DoActionSheet.m b/TestActionSheet/DoActionSheet/DoActionSheet.m index 98fd1da..c936856 100644 --- a/TestActionSheet/DoActionSheet/DoActionSheet.m +++ b/TestActionSheet/DoActionSheet/DoActionSheet.m @@ -220,26 +220,29 @@ - (void)showActionSheet // add buttons int nTagIndex = 0; - for (NSString *str in _aButtons) + for (id str in _aButtons) { - UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom]; - bt.tag = nTagIndex; - [bt setTitle:str forState:UIControlStateNormal]; - - [self setButtonAttributes:bt cancel:NO]; - bt.frame = CGRectMake(self.doButtonInset.left, dYContent, - _vActionSheet.frame.size.width - (self.doButtonInset.left + self.doButtonInset.right), (self.doButtonHeight > 0) ? self.doButtonHeight : DO_AS_BUTTON_HEIGHT); - - dYContent += ((self.doButtonHeight > 0) ? self.doButtonHeight : DO_AS_BUTTON_HEIGHT) + self.doButtonInset.bottom; - - [sc addSubview:bt]; - - if (nTagIndex == _nDestructiveIndex) - { - bt.backgroundColor = (self.doDestructiveColor == nil) ? DO_AS_DESTRUCTIVE_COLOR : self.doDestructiveColor; - [bt setTitleColor:(self.doDestructiveTextColor == nil) ? DO_AS_DESTRUCTIVE_TEXT_COLOR : self.doDestructiveTextColor forState:UIControlStateNormal]; + if ([str isKindOfClass:[UIButton class]]) { + [sc addSubview:str]; + }else{ + UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom]; + bt.tag = nTagIndex; + [bt setTitle:str forState:UIControlStateNormal]; + + [self setButtonAttributes:bt cancel:NO]; + bt.frame = CGRectMake(self.doButtonInset.left, dYContent, + _vActionSheet.frame.size.width - (self.doButtonInset.left + self.doButtonInset.right), (self.doButtonHeight > 0) ? self.doButtonHeight : DO_AS_BUTTON_HEIGHT); + + dYContent += ((self.doButtonHeight > 0) ? self.doButtonHeight : DO_AS_BUTTON_HEIGHT) + self.doButtonInset.bottom; + + [sc addSubview:bt]; + + if (nTagIndex == _nDestructiveIndex) + { + bt.backgroundColor = (self.doDestructiveColor == nil) ? DO_AS_DESTRUCTIVE_COLOR : self.doDestructiveColor; + [bt setTitleColor:(self.doDestructiveTextColor == nil) ? DO_AS_DESTRUCTIVE_TEXT_COLOR : self.doDestructiveTextColor forState:UIControlStateNormal]; + } } - nTagIndex += 1; } From c4d5e96fcf468c998df73228ffb61a554db46fac Mon Sep 17 00:00:00 2001 From: Benny Liu Date: Thu, 17 Jul 2014 10:30:52 +0800 Subject: [PATCH 2/5] update --- ...Sheet.podspec => DoActionSheetFork.podspec | 10 +++--- TestActionSheet/DoActionSheet/DoActionSheet.m | 35 ++++++++++--------- 2 files changed, 23 insertions(+), 22 deletions(-) rename DoActionSheet.podspec => DoActionSheetFork.podspec (57%) diff --git a/DoActionSheet.podspec b/DoActionSheetFork.podspec similarity index 57% rename from DoActionSheet.podspec rename to DoActionSheetFork.podspec index 32c4557..25e24a7 100644 --- a/DoActionSheet.podspec +++ b/DoActionSheetFork.podspec @@ -1,11 +1,11 @@ Pod::Spec.new do |s| - s.name = 'DoActionSheet' - s.version = '1.0' - s.author = { 'JackShi' => 'shiguifei@gmail.com' } - s.homepage = 'https://github.com/donobono/DoActionSheet' + s.name = 'DoActionSheetFork' + s.version = '1.1' + s.author = { 'beiliubei' => 'beiliubei@gmail.com' } + s.homepage = 'https://github.com/beiliubei/DoActionSheet.git' s.summary = 'An replacement for UIActionSheet : block-based, customizable theme, easy to use with image or map' s.license = { :type => 'MIT', :file => 'License' } - s.source = { :git => 'https://github.com/donobono/DoActionSheet.git', :tag => '1.0' } + s.source = { :git => 'https://github.com/beiliubei/DoActionSheet.git', :tag => '1.1' } s.source_files = 'TestActionSheet/3rdSource/UIImage-ResizeMagick/*.{h,m}','TestActionSheet/DoActionSheet/*.{h,m}' s.platform = :ios s.requires_arc = true diff --git a/TestActionSheet/DoActionSheet/DoActionSheet.m b/TestActionSheet/DoActionSheet/DoActionSheet.m index c936856..a7aecd2 100644 --- a/TestActionSheet/DoActionSheet/DoActionSheet.m +++ b/TestActionSheet/DoActionSheet/DoActionSheet.m @@ -222,27 +222,28 @@ - (void)showActionSheet int nTagIndex = 0; for (id str in _aButtons) { + UIButton *bt; if ([str isKindOfClass:[UIButton class]]) { - [sc addSubview:str]; + bt = (UIButton *)str; }else{ - UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom]; - bt.tag = nTagIndex; + bt = [UIButton buttonWithType:UIButtonTypeCustom]; [bt setTitle:str forState:UIControlStateNormal]; - - [self setButtonAttributes:bt cancel:NO]; - bt.frame = CGRectMake(self.doButtonInset.left, dYContent, - _vActionSheet.frame.size.width - (self.doButtonInset.left + self.doButtonInset.right), (self.doButtonHeight > 0) ? self.doButtonHeight : DO_AS_BUTTON_HEIGHT); - - dYContent += ((self.doButtonHeight > 0) ? self.doButtonHeight : DO_AS_BUTTON_HEIGHT) + self.doButtonInset.bottom; - - [sc addSubview:bt]; - - if (nTagIndex == _nDestructiveIndex) - { - bt.backgroundColor = (self.doDestructiveColor == nil) ? DO_AS_DESTRUCTIVE_COLOR : self.doDestructiveColor; - [bt setTitleColor:(self.doDestructiveTextColor == nil) ? DO_AS_DESTRUCTIVE_TEXT_COLOR : self.doDestructiveTextColor forState:UIControlStateNormal]; - } } + bt.tag = nTagIndex; + [self setButtonAttributes:bt cancel:NO]; + bt.frame = CGRectMake(self.doButtonInset.left, dYContent, + _vActionSheet.frame.size.width - (self.doButtonInset.left + self.doButtonInset.right), (self.doButtonHeight > 0) ? self.doButtonHeight : DO_AS_BUTTON_HEIGHT); + + dYContent += ((self.doButtonHeight > 0) ? self.doButtonHeight : DO_AS_BUTTON_HEIGHT) + self.doButtonInset.bottom; + + [sc addSubview:bt]; + + if (nTagIndex == _nDestructiveIndex) + { + bt.backgroundColor = (self.doDestructiveColor == nil) ? DO_AS_DESTRUCTIVE_COLOR : self.doDestructiveColor; + [bt setTitleColor:(self.doDestructiveTextColor == nil) ? DO_AS_DESTRUCTIVE_TEXT_COLOR : self.doDestructiveTextColor forState:UIControlStateNormal]; + } + nTagIndex += 1; } From 999e42d22f0a7836a13dbec3d984ff5d429c2656 Mon Sep 17 00:00:00 2001 From: Benny Liu Date: Thu, 17 Jul 2014 10:33:13 +0800 Subject: [PATCH 3/5] update --- DoActionSheetFork.podspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DoActionSheetFork.podspec b/DoActionSheetFork.podspec index 25e24a7..35a891d 100644 --- a/DoActionSheetFork.podspec +++ b/DoActionSheetFork.podspec @@ -1,11 +1,11 @@ Pod::Spec.new do |s| s.name = 'DoActionSheetFork' - s.version = '1.1' + s.version = '1.1.1' s.author = { 'beiliubei' => 'beiliubei@gmail.com' } s.homepage = 'https://github.com/beiliubei/DoActionSheet.git' s.summary = 'An replacement for UIActionSheet : block-based, customizable theme, easy to use with image or map' s.license = { :type => 'MIT', :file => 'License' } - s.source = { :git => 'https://github.com/beiliubei/DoActionSheet.git', :tag => '1.1' } + s.source = { :git => 'https://github.com/beiliubei/DoActionSheet.git', :tag => '1.1.1' } s.source_files = 'TestActionSheet/3rdSource/UIImage-ResizeMagick/*.{h,m}','TestActionSheet/DoActionSheet/*.{h,m}' s.platform = :ios s.requires_arc = true From c4f9135b1bbe2d46103c221843c3963d7b883ea4 Mon Sep 17 00:00:00 2001 From: Benny Liu Date: Mon, 21 Jul 2014 09:54:43 +0800 Subject: [PATCH 4/5] underline enable --- README.md | 10 ++++++++++ TestActionSheet/DoActionSheet/DoActionSheet.h | 3 +++ TestActionSheet/DoActionSheet/DoActionSheet.m | 12 +++++++----- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index ccd8ef1..8c75510 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,15 @@ DoActionSheet - iOS 7.0 and greater - ARC +## ChangeLog +### 1.1.1 +1. custom buttons enable + +### 1.1.2 +1. underLineEnable enable + + @property (assign, nonatomic) BOOL underLineEnable; + ## Examples @@ -86,6 +95,7 @@ vActionSheet.nDestructiveIndex = 2; #define DO_DESTRUCTIVE_TEXT_COLOR DO_RGB(255, 255, 255) ``` + ## Credits DoActionSheet was created by Dono Cho. diff --git a/TestActionSheet/DoActionSheet/DoActionSheet.h b/TestActionSheet/DoActionSheet/DoActionSheet.h index ae34d26..b75c24c 100644 --- a/TestActionSheet/DoActionSheet/DoActionSheet.h +++ b/TestActionSheet/DoActionSheet/DoActionSheet.h @@ -152,6 +152,9 @@ typedef void(^DoActionSheetHandler)(int nResult); // button height @property (readwrite) CGFloat doButtonHeight; +// underline enable +@property (assign, nonatomic) BOOL underLineEnable; + // with cancel button and other buttons - (void)showC:(NSString *)strTitle diff --git a/TestActionSheet/DoActionSheet/DoActionSheet.m b/TestActionSheet/DoActionSheet/DoActionSheet.m index a7aecd2..244e07c 100644 --- a/TestActionSheet/DoActionSheet/DoActionSheet.m +++ b/TestActionSheet/DoActionSheet/DoActionSheet.m @@ -194,11 +194,13 @@ - (void)showActionSheet dHeight = lbTitle.frame.size.height + self.doTitleInset.bottom; // underline - UIView *vLine = [[UIView alloc] initWithFrame:CGRectMake(lbTitle.frame.origin.x, lbTitle.frame.origin.y + lbTitle.frame.size.height - 3, lbTitle.frame.size.width, 0.5)]; - vLine.backgroundColor = (self.doTitleTextColor == nil) ? DO_AS_TITLE_TEXT_COLOR : self.doTitleTextColor; - vLine.alpha = 0.2; - vLine.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; - [_vActionSheet addSubview:vLine]; + if (_underLineEnable) { + UIView *vLine = [[UIView alloc] initWithFrame:CGRectMake(lbTitle.frame.origin.x, lbTitle.frame.origin.y + lbTitle.frame.size.height - 3, lbTitle.frame.size.width, 0.5)]; + vLine.backgroundColor = (self.doTitleTextColor == nil) ? DO_AS_TITLE_TEXT_COLOR : self.doTitleTextColor; + vLine.alpha = 0.2; + vLine.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; + [_vActionSheet addSubview:vLine]; + } } else dHeight += self.doTitleInset.bottom; From 7c39ca25a903cb73714e30c8c7bbfc723f63deae Mon Sep 17 00:00:00 2001 From: Benny Liu Date: Mon, 21 Jul 2014 09:56:19 +0800 Subject: [PATCH 5/5] update --- DoActionSheetFork.podspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DoActionSheetFork.podspec b/DoActionSheetFork.podspec index 35a891d..682ec0f 100644 --- a/DoActionSheetFork.podspec +++ b/DoActionSheetFork.podspec @@ -1,11 +1,11 @@ Pod::Spec.new do |s| s.name = 'DoActionSheetFork' - s.version = '1.1.1' + s.version = '1.1.2' s.author = { 'beiliubei' => 'beiliubei@gmail.com' } s.homepage = 'https://github.com/beiliubei/DoActionSheet.git' s.summary = 'An replacement for UIActionSheet : block-based, customizable theme, easy to use with image or map' s.license = { :type => 'MIT', :file => 'License' } - s.source = { :git => 'https://github.com/beiliubei/DoActionSheet.git', :tag => '1.1.1' } + s.source = { :git => 'https://github.com/beiliubei/DoActionSheet.git', :tag => '1.1.2' } s.source_files = 'TestActionSheet/3rdSource/UIImage-ResizeMagick/*.{h,m}','TestActionSheet/DoActionSheet/*.{h,m}' s.platform = :ios s.requires_arc = true