From ddb543e6558be34ba84d203409cddc5309add1fc Mon Sep 17 00:00:00 2001 From: Dal Rupnik Date: Thu, 20 Oct 2016 21:58:53 +0200 Subject: [PATCH 1/9] Added support for stying buttons --- .DS_Store | Bin 0 -> 6148 bytes JTAlertView/JTAlertView.h | 1 + JTAlertView/JTAlertView.m | 19 +++++++++++++++---- 3 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..d90ae2f254b7eab002ea69cced828ce7b02b53b5 GIT binary patch literal 6148 zcmeHKyGjH>5Ukb<4onVA4Cfd8gY~#eOci4vXCSQH;R6jf^1J*rs~^d-2y$R@R6|eA z^mNTI6>M(3Nv;u6=mKtJMt zpka+q+~FBJ-`l)C^!M9s?-ZF7kOERb3P=Gdu%`l5NarVe@NiF&xHu^b*A80b*A;Br-y?q!N>A)nZuE8E=)>6%L6>hgI`ob+c86VsSgq zZ;=k`5;aNzDKJ*xIF}2r|7-d${r{Mxl@yQy2c>|`R#&SfpH#JV@;I-xjebk_oNu}t q=Rx5R<(L@dm literal 0 HcmV?d00001 diff --git a/JTAlertView/JTAlertView.h b/JTAlertView/JTAlertView.h index 5f67ac9..c996acd 100644 --- a/JTAlertView/JTAlertView.h +++ b/JTAlertView/JTAlertView.h @@ -50,6 +50,7 @@ typedef NS_ENUM(NSInteger, JTAlertViewStyle) { - (void)addButtonWithTitle:(NSString *)titleText style:(JTAlertViewStyle)style action:(void (^)(JTAlertView *alertView))action; - (void)addButtonWithTitle:(NSString *)titleText style:(JTAlertViewStyle)style forControlEvents:(UIControlEvents)controlEvents action:(void (^)(JTAlertView *alertView))action; - (void)addButtonWithTitle:(NSString *)titleText font:(UIFont *)font style:(JTAlertViewStyle)style forControlEvents:(UIControlEvents)controlEvents action:(void (^)(JTAlertView *alertView))action; +- (void)addButtonWithTitle:(NSString *)titleText font:(UIFont *)font style:(JTAlertViewStyle)style forControlEvents:(UIControlEvents)controlEvents styling:(void (^)(UIButton *button))styling action:(void (^)(JTAlertView *alertView))action; // Displaying - (void)show; diff --git a/JTAlertView/JTAlertView.m b/JTAlertView/JTAlertView.m index 7cb4e3b..3224957 100644 --- a/JTAlertView/JTAlertView.m +++ b/JTAlertView/JTAlertView.m @@ -86,14 +86,25 @@ - (void)addButtonWithTitle:(NSString *)titleText style:(JTAlertViewStyle)style a } - (void)addButtonWithTitle:(NSString *)titleText style:(JTAlertViewStyle)style forControlEvents:(UIControlEvents)controlEvents action:(void (^)(JTAlertView *alertView))action { - [self addButtonWithTitle:titleText font:nil style:style forControlEvents:controlEvents action:action]; + [self addButtonWithTitle:titleText font:nil style:style forControlEvents:controlEvents styling:nil action:action]; } - (void)addButtonWithTitle:(NSString *)titleText font:(UIFont *)font style:(JTAlertViewStyle)style forControlEvents:(UIControlEvents)controlEvents action:(void (^)(JTAlertView *alertView))action { + [self addButtonWithTitle:titleText font:font style:style forControlEvents:controlEvents styling:nil action:action]; +} + +- (void)addButtonWithTitle:(NSString *)titleText font:(UIFont *)font style:(JTAlertViewStyle)style forControlEvents:(UIControlEvents)controlEvents styling:(void (^)(UIButton *button))styling action:(void (^)(JTAlertView *alertView))action { UIBlockButton *btn = [UIBlockButton buttonWithType:UIButtonTypeSystem]; - [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; - [btn setBackgroundColor:[UIColor whiteColor]]; + + if (styling != nil) { + styling(btn); + } + else { + [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; + [btn setBackgroundColor:[UIColor whiteColor]]; + } + [btn setTitle:titleText forState:UIControlStateNormal]; [btn handleControlEvent:controlEvents withBlock:action]; @@ -433,4 +444,4 @@ - (void)callActionBlock { _actionBlock((JTAlertView *)self.superview); } -@end \ No newline at end of file +@end From 3fe4dfcf700f034055611fca0350164c90128f08 Mon Sep 17 00:00:00 2001 From: Dal Rupnik Date: Thu, 20 Oct 2016 22:00:00 +0200 Subject: [PATCH 2/9] Conditional override for stying title --- JTAlertView/JTAlertView.m | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/JTAlertView/JTAlertView.m b/JTAlertView/JTAlertView.m index 3224957..32ec0fb 100644 --- a/JTAlertView/JTAlertView.m +++ b/JTAlertView/JTAlertView.m @@ -118,7 +118,10 @@ - (void)addButtonWithTitle:(NSString *)titleText font:(UIFont *)font style:(JTAl break; case JTAlertViewStyleDestructive: btn.titleLabel.font = [self boldForFont:_font withSize:kBtnFontSize] ? [self boldForFont:_font withSize:kBtnFontSize] : [_font fontWithSize:kBtnFontSize]; - [btn setTitleColor:[UIColor colorWithRed:0.906 green:0.298 blue:0.235 alpha:1] forState:UIControlStateNormal]; + + if (styling == nil) { + [btn setTitleColor:[UIColor colorWithRed:0.906 green:0.298 blue:0.235 alpha:1] forState:UIControlStateNormal]; + } break; default: break; @@ -133,7 +136,10 @@ - (void)addButtonWithTitle:(NSString *)titleText font:(UIFont *)font style:(JTAl break; case JTAlertViewStyleDestructive: btn.titleLabel.font = [self boldForFont:font withSize:font.pointSize] ? [self boldForFont:font withSize:font.pointSize] : font; - [btn setTitleColor:[UIColor colorWithRed:0.906 green:0.298 blue:0.235 alpha:1] forState:UIControlStateNormal]; + + if (styling == nil) { + [btn setTitleColor:[UIColor colorWithRed:0.906 green:0.298 blue:0.235 alpha:1] forState:UIControlStateNormal]; + } break; default: break; From 357c203b3999647ff9258aa0e1c704fd8aa2c6c2 Mon Sep 17 00:00:00 2001 From: Dal Rupnik Date: Thu, 20 Oct 2016 22:04:39 +0200 Subject: [PATCH 3/9] Nullability support for Swift compatibility --- JTAlertView/JTAlertView.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/JTAlertView/JTAlertView.h b/JTAlertView/JTAlertView.h index c996acd..b9309f9 100644 --- a/JTAlertView/JTAlertView.h +++ b/JTAlertView/JTAlertView.h @@ -7,6 +7,8 @@ #import +NS_ASSUME_NONNULL_BEGIN + @interface JTAlertView : UIView /** In Cancel and Destructive case JTAlertView will try to use bold version of your font (Must be in format FontName-Bold) */ @@ -42,21 +44,21 @@ typedef NS_ENUM(NSInteger, JTAlertViewStyle) { @property (nonatomic, assign, getter=isBackgroundShadow) bool backgroundShadow; // Initializers -+ (instancetype)alertWithTitle:(NSString *)titleText andImage:(UIImage *)image; -- (instancetype)initWithTitle:(NSString *)titleText andImage:(UIImage *)image; ++ (instancetype)alertWithTitle:(NSString * _Nullable)titleText andImage:(UIImage * _Nullable)image; +- (instancetype)initWithTitle:(NSString * _Nullable)titleText andImage:(UIImage * _Nullable)image; // Buttons - (void)addButtonWithTitle:(NSString *)titleText action:(void (^)(JTAlertView *alertView))action; - (void)addButtonWithTitle:(NSString *)titleText style:(JTAlertViewStyle)style action:(void (^)(JTAlertView *alertView))action; - (void)addButtonWithTitle:(NSString *)titleText style:(JTAlertViewStyle)style forControlEvents:(UIControlEvents)controlEvents action:(void (^)(JTAlertView *alertView))action; -- (void)addButtonWithTitle:(NSString *)titleText font:(UIFont *)font style:(JTAlertViewStyle)style forControlEvents:(UIControlEvents)controlEvents action:(void (^)(JTAlertView *alertView))action; -- (void)addButtonWithTitle:(NSString *)titleText font:(UIFont *)font style:(JTAlertViewStyle)style forControlEvents:(UIControlEvents)controlEvents styling:(void (^)(UIButton *button))styling action:(void (^)(JTAlertView *alertView))action; +- (void)addButtonWithTitle:(NSString *)titleText font:(UIFont * _Nullable )font style:(JTAlertViewStyle)style forControlEvents:(UIControlEvents)controlEvents action:(void (^)(JTAlertView *alertView))action; +- (void)addButtonWithTitle:(NSString *)titleText font:(UIFont * _Nullable)font style:(JTAlertViewStyle)style forControlEvents:(UIControlEvents)controlEvents styling:(void (^ _Nullable)(UIButton *button))styling action:(void (^)(JTAlertView *alertView))action; // Displaying - (void)show; -- (void)showInSuperview:(UIView *)superView withCompletion:(void (^)())completion animated:(bool)animated; +- (void)showInSuperview:(UIView *)superView withCompletion:(void (^ _Nullable)())completion animated:(bool)animated; - (void)hide; -- (void)hideWithCompletion:(void (^)())completion animated:(bool)animated; +- (void)hideWithCompletion:( void (^ _Nullable )())completion animated:(bool)animated; - (void)hideWithDelay:(NSTimeInterval)delay animated:(bool)animated; @end @@ -70,3 +72,5 @@ typedef void (^ActionBlock)(JTAlertView *alertView); - (void)handleControlEvent:(UIControlEvents)event withBlock:(ActionBlock)action; @end + +NS_ASSUME_NONNULL_END From a629fd53fb5ee10413a3b770fc2bf8dd9cbfe03b Mon Sep 17 00:00:00 2001 From: Dal Rupnik Date: Thu, 20 Oct 2016 22:06:05 +0200 Subject: [PATCH 4/9] Updated project for Xcode 8 --- .../JTAlertView Example.xcodeproj/project.pbxproj | 11 ++++++++++- JTAlertView Example/JTAlertView Example/Info.plist | 2 +- .../JTAlertView ExampleTests/Info.plist | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/JTAlertView Example/JTAlertView Example.xcodeproj/project.pbxproj b/JTAlertView Example/JTAlertView Example.xcodeproj/project.pbxproj index a7268ff..7c3a017 100644 --- a/JTAlertView Example/JTAlertView Example.xcodeproj/project.pbxproj +++ b/JTAlertView Example/JTAlertView Example.xcodeproj/project.pbxproj @@ -177,7 +177,7 @@ 3BD1B19E1B2CBE7600621F68 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0630; + LastUpgradeCheck = 0800; ORGANIZATIONNAME = "Jakub Truhlar"; TargetAttributes = { 3BD1B1A51B2CBE7600621F68 = { @@ -291,14 +291,17 @@ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; @@ -334,8 +337,10 @@ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -364,6 +369,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = "JTAlertView Example/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "com.jakubtruhlar.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Debug; @@ -374,6 +380,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = "JTAlertView Example/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "com.jakubtruhlar.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Release; @@ -392,6 +399,7 @@ ); INFOPLIST_FILE = "JTAlertView ExampleTests/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "com.jakubtruhlar.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/JTAlertView Example.app/JTAlertView Example"; }; @@ -407,6 +415,7 @@ ); INFOPLIST_FILE = "JTAlertView ExampleTests/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "com.jakubtruhlar.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/JTAlertView Example.app/JTAlertView Example"; }; diff --git a/JTAlertView Example/JTAlertView Example/Info.plist b/JTAlertView Example/JTAlertView Example/Info.plist index d532dfe..8a1e9be 100644 --- a/JTAlertView Example/JTAlertView Example/Info.plist +++ b/JTAlertView Example/JTAlertView Example/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - com.jakubtruhlar.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/JTAlertView Example/JTAlertView ExampleTests/Info.plist b/JTAlertView Example/JTAlertView ExampleTests/Info.plist index f082bc0..ba72822 100644 --- a/JTAlertView Example/JTAlertView ExampleTests/Info.plist +++ b/JTAlertView Example/JTAlertView ExampleTests/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - com.jakubtruhlar.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName From d366c09ad3c314c0fa4fbb259325ac26fb4d69f7 Mon Sep 17 00:00:00 2001 From: Dal Rupnik Date: Thu, 20 Oct 2016 22:14:27 +0200 Subject: [PATCH 5/9] Refactored default styling into a block --- JTAlertView/JTAlertView.h | 4 +- JTAlertView/JTAlertView.m | 87 +++++++++++++++++++-------------------- 2 files changed, 45 insertions(+), 46 deletions(-) diff --git a/JTAlertView/JTAlertView.h b/JTAlertView/JTAlertView.h index b9309f9..1daf20c 100644 --- a/JTAlertView/JTAlertView.h +++ b/JTAlertView/JTAlertView.h @@ -18,6 +18,8 @@ typedef NS_ENUM(NSInteger, JTAlertViewStyle) { JTAlertViewStyleDestructive }; +typedef void (^JTAlertViewStyling)(UIButton* btn); + // Public properties /** Size of the alertView. Default is 240.0, 290.0. */ @property (nonatomic, assign) CGSize size; @@ -52,7 +54,7 @@ typedef NS_ENUM(NSInteger, JTAlertViewStyle) { - (void)addButtonWithTitle:(NSString *)titleText style:(JTAlertViewStyle)style action:(void (^)(JTAlertView *alertView))action; - (void)addButtonWithTitle:(NSString *)titleText style:(JTAlertViewStyle)style forControlEvents:(UIControlEvents)controlEvents action:(void (^)(JTAlertView *alertView))action; - (void)addButtonWithTitle:(NSString *)titleText font:(UIFont * _Nullable )font style:(JTAlertViewStyle)style forControlEvents:(UIControlEvents)controlEvents action:(void (^)(JTAlertView *alertView))action; -- (void)addButtonWithTitle:(NSString *)titleText font:(UIFont * _Nullable)font style:(JTAlertViewStyle)style forControlEvents:(UIControlEvents)controlEvents styling:(void (^ _Nullable)(UIButton *button))styling action:(void (^)(JTAlertView *alertView))action; +- (void)addButtonWithTitle:(NSString *)titleText styling:(JTAlertViewStyling _Nullable)styling forControlEvents:(UIControlEvents)controlEvents action:(void (^)(JTAlertView *alertView))action; // Displaying - (void)show; diff --git a/JTAlertView/JTAlertView.m b/JTAlertView/JTAlertView.m index 32ec0fb..0c6caa7 100644 --- a/JTAlertView/JTAlertView.m +++ b/JTAlertView/JTAlertView.m @@ -86,66 +86,63 @@ - (void)addButtonWithTitle:(NSString *)titleText style:(JTAlertViewStyle)style a } - (void)addButtonWithTitle:(NSString *)titleText style:(JTAlertViewStyle)style forControlEvents:(UIControlEvents)controlEvents action:(void (^)(JTAlertView *alertView))action { - [self addButtonWithTitle:titleText font:nil style:style forControlEvents:controlEvents styling:nil action:action]; + [self addButtonWithTitle:titleText font:nil style:style forControlEvents:controlEvents action:action]; } - (void)addButtonWithTitle:(NSString *)titleText font:(UIFont *)font style:(JTAlertViewStyle)style forControlEvents:(UIControlEvents)controlEvents action:(void (^)(JTAlertView *alertView))action { - [self addButtonWithTitle:titleText font:font style:style forControlEvents:controlEvents styling:nil action:action]; + + JTAlertViewStyling styling = ^(UIButton* btn) { + [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; + [btn setBackgroundColor:[UIColor whiteColor]]; + if (!font) { + switch (style) { + case JTAlertViewStyleDefault: + btn.titleLabel.font = [_font fontWithSize:kBtnFontSize]; + break; + case JTAlertViewStyleCancel: + btn.titleLabel.font = [self boldForFont:_font withSize:kBtnFontSize] ? [self boldForFont:_font withSize:kBtnFontSize] : [_font fontWithSize:kBtnFontSize]; + break; + case JTAlertViewStyleDestructive: + btn.titleLabel.font = [self boldForFont:_font withSize:kBtnFontSize] ? [self boldForFont:_font withSize:kBtnFontSize] : [_font fontWithSize:kBtnFontSize]; + + [btn setTitleColor:[UIColor colorWithRed:0.906 green:0.298 blue:0.235 alpha:1] forState:UIControlStateNormal]; + break; + default: + break; + } + } else { + switch (style) { + case JTAlertViewStyleDefault: + btn.titleLabel.font = font; + break; + case JTAlertViewStyleCancel: + btn.titleLabel.font = [self boldForFont:font withSize:font.pointSize] ? [self boldForFont:font withSize:font.pointSize] : font; + break; + case JTAlertViewStyleDestructive: + btn.titleLabel.font = [self boldForFont:font withSize:font.pointSize] ? [self boldForFont:font withSize:font.pointSize] : font; + + [btn setTitleColor:[UIColor colorWithRed:0.906 green:0.298 blue:0.235 alpha:1] forState:UIControlStateNormal]; + break; + default: + break; + } + } + }; + + [self addButtonWithTitle:titleText styling:styling forControlEvents:controlEvents action:action]; } -- (void)addButtonWithTitle:(NSString *)titleText font:(UIFont *)font style:(JTAlertViewStyle)style forControlEvents:(UIControlEvents)controlEvents styling:(void (^)(UIButton *button))styling action:(void (^)(JTAlertView *alertView))action { +- (void)addButtonWithTitle:(NSString *)titleText styling:(JTAlertViewStyling)styling forControlEvents:(UIControlEvents)controlEvents action:(void (^)(JTAlertView *alertView))action { UIBlockButton *btn = [UIBlockButton buttonWithType:UIButtonTypeSystem]; if (styling != nil) { styling(btn); } - else { - [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; - [btn setBackgroundColor:[UIColor whiteColor]]; - } [btn setTitle:titleText forState:UIControlStateNormal]; [btn handleControlEvent:controlEvents withBlock:action]; - if (!font) { - switch (style) { - case JTAlertViewStyleDefault: - btn.titleLabel.font = [_font fontWithSize:kBtnFontSize]; - break; - case JTAlertViewStyleCancel: - btn.titleLabel.font = [self boldForFont:_font withSize:kBtnFontSize] ? [self boldForFont:_font withSize:kBtnFontSize] : [_font fontWithSize:kBtnFontSize]; - break; - case JTAlertViewStyleDestructive: - btn.titleLabel.font = [self boldForFont:_font withSize:kBtnFontSize] ? [self boldForFont:_font withSize:kBtnFontSize] : [_font fontWithSize:kBtnFontSize]; - - if (styling == nil) { - [btn setTitleColor:[UIColor colorWithRed:0.906 green:0.298 blue:0.235 alpha:1] forState:UIControlStateNormal]; - } - break; - default: - break; - } - } else { - switch (style) { - case JTAlertViewStyleDefault: - btn.titleLabel.font = font; - break; - case JTAlertViewStyleCancel: - btn.titleLabel.font = [self boldForFont:font withSize:font.pointSize] ? [self boldForFont:font withSize:font.pointSize] : font; - break; - case JTAlertViewStyleDestructive: - btn.titleLabel.font = [self boldForFont:font withSize:font.pointSize] ? [self boldForFont:font withSize:font.pointSize] : font; - - if (styling == nil) { - [btn setTitleColor:[UIColor colorWithRed:0.906 green:0.298 blue:0.235 alpha:1] forState:UIControlStateNormal]; - } - break; - default: - break; - } - } - [self.btns addObject:btn]; [self layoutBtns]; From 547d88d177f8370ada282a9ccefc374ed3e7ba3b Mon Sep 17 00:00:00 2001 From: Dal Rupnik Date: Thu, 20 Oct 2016 22:39:47 +0200 Subject: [PATCH 6/9] Commented main method --- JTAlertView/JTAlertView.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/JTAlertView/JTAlertView.h b/JTAlertView/JTAlertView.h index 1daf20c..3cf7127 100644 --- a/JTAlertView/JTAlertView.h +++ b/JTAlertView/JTAlertView.h @@ -54,7 +54,9 @@ typedef void (^JTAlertViewStyling)(UIButton* btn); - (void)addButtonWithTitle:(NSString *)titleText style:(JTAlertViewStyle)style action:(void (^)(JTAlertView *alertView))action; - (void)addButtonWithTitle:(NSString *)titleText style:(JTAlertViewStyle)style forControlEvents:(UIControlEvents)controlEvents action:(void (^)(JTAlertView *alertView))action; - (void)addButtonWithTitle:(NSString *)titleText font:(UIFont * _Nullable )font style:(JTAlertViewStyle)style forControlEvents:(UIControlEvents)controlEvents action:(void (^)(JTAlertView *alertView))action; -- (void)addButtonWithTitle:(NSString *)titleText styling:(JTAlertViewStyling _Nullable)styling forControlEvents:(UIControlEvents)controlEvents action:(void (^)(JTAlertView *alertView))action; + +/** Designated method to adda a button. Provide a styling block to update custom styling to provided button, overriding default JTAlertViewStyle parameter and font. */ +- (void)addButtonWithTitle:(NSString *)titleText styling:(JTAlertViewStyling _Nullable)styling forControlEvents:(UIControlEvents)controlEvents action:(void (^)(JTAlertView *alertView))action; // Displaying - (void)show; From a802ac60a894a49dd6be974aded32c215daf371f Mon Sep 17 00:00:00 2001 From: Dal Rupnik Date: Thu, 20 Oct 2016 22:48:33 +0200 Subject: [PATCH 7/9] Added separator color as property --- JTAlertView/JTAlertView.h | 3 +++ JTAlertView/JTAlertView.m | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/JTAlertView/JTAlertView.h b/JTAlertView/JTAlertView.h index 3cf7127..e5d73a2 100644 --- a/JTAlertView/JTAlertView.h +++ b/JTAlertView/JTAlertView.h @@ -33,6 +33,9 @@ typedef void (^JTAlertViewStyling)(UIButton* btn); /** Image overlay. Default overlay is gray with half alpha. */ @property (nonatomic, strong) UIColor *overlayColor; +/** Button separator color. Default is 97% white. */ +@property (nonatomic, strong) UIColor *separatorColor; + /** Font applied on title and alertView buttons. AlertView buttons will ignore this font's size but not the style (In case you want to setup custom font for your buttons, use font parameter in method instead). Default is Helvetica Neue Medium with 21.0 size. */ @property (nonatomic, strong) UIFont *font; diff --git a/JTAlertView/JTAlertView.m b/JTAlertView/JTAlertView.m index 0c6caa7..7cca762 100644 --- a/JTAlertView/JTAlertView.m +++ b/JTAlertView/JTAlertView.m @@ -179,7 +179,7 @@ - (void)layoutBtns { - (void)addSeparatorInView:(UIView *)superview withTag:(NSInteger)tag andFrame:(CGRect)frame { UIView *separator = [[UIView alloc] initWithFrame:frame]; - separator.backgroundColor = [UIColor colorWithWhite:kSeparatorColorValue alpha:1.0]; + separator.backgroundColor = self.separatorColor; separator.tag = tag; [superview insertSubview:separator atIndex:2]; } @@ -373,6 +373,7 @@ - (void)defaultSetup { _titleColor = [UIColor whiteColor]; _titleShadow = true; _backgroundShadow = false; + _separatorColor = [UIColor colorWithWhite:kSeparatorColorValue alpha:1.0]; } - (void)noAlpha { From 86c86ef7912a978d3757f5cfbbdc10c51da69ee4 Mon Sep 17 00:00:00 2001 From: Dal Rupnik Date: Fri, 21 Oct 2016 02:53:30 +0200 Subject: [PATCH 8/9] Cleaned up spaces --- JTAlertView/JTAlertView.m | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/JTAlertView/JTAlertView.m b/JTAlertView/JTAlertView.m index 7cca762..a6f5d34 100644 --- a/JTAlertView/JTAlertView.m +++ b/JTAlertView/JTAlertView.m @@ -76,12 +76,10 @@ + (instancetype)alertWithTitle:(NSString *)titleText andImage:(UIImage *)image { #pragma mark - Buttons handle - (void)addButtonWithTitle:(NSString *)titleText action:(void (^)(JTAlertView *alertView))action { - [self addButtonWithTitle:titleText style:JTAlertViewStyleDefault action:action]; } - (void)addButtonWithTitle:(NSString *)titleText style:(JTAlertViewStyle)style action:(void (^)(JTAlertView *alertView))action { - [self addButtonWithTitle:titleText style:style forControlEvents:UIControlEventTouchUpInside action:action]; } @@ -90,7 +88,6 @@ - (void)addButtonWithTitle:(NSString *)titleText style:(JTAlertViewStyle)style f } - (void)addButtonWithTitle:(NSString *)titleText font:(UIFont *)font style:(JTAlertViewStyle)style forControlEvents:(UIControlEvents)controlEvents action:(void (^)(JTAlertView *alertView))action { - JTAlertViewStyling styling = ^(UIButton* btn) { [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; [btn setBackgroundColor:[UIColor whiteColor]]; @@ -132,8 +129,7 @@ - (void)addButtonWithTitle:(NSString *)titleText font:(UIFont *)font style:(JTAl [self addButtonWithTitle:titleText styling:styling forControlEvents:controlEvents action:action]; } -- (void)addButtonWithTitle:(NSString *)titleText styling:(JTAlertViewStyling)styling forControlEvents:(UIControlEvents)controlEvents action:(void (^)(JTAlertView *alertView))action { - +- (void)addButtonWithTitle:(NSString *)titleText styling:(JTAlertViewStyling)styling forControlEvents:(UIControlEvents)controlEvents action:(void (^)(JTAlertView *alertView))action { UIBlockButton *btn = [UIBlockButton buttonWithType:UIButtonTypeSystem]; if (styling != nil) { @@ -257,7 +253,6 @@ - (void)show { } - (void)showInSuperview:(UIView *)superView withCompletion:(void (^)())completion animated:(bool)animated { - if (self.btns.count == 0) { [self applyAppearanceConsideringButtons:false]; } else { From 6eb75c6864026dcddd4b1a52bc2afc74f847b9ff Mon Sep 17 00:00:00 2001 From: Dal Rupnik Date: Fri, 21 Oct 2016 14:44:08 +0200 Subject: [PATCH 9/9] Fixed spaces for pointers --- JTAlertView/JTAlertView.h | 4 ++-- JTAlertView/JTAlertView.m | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/JTAlertView/JTAlertView.h b/JTAlertView/JTAlertView.h index e5d73a2..bdeaee2 100644 --- a/JTAlertView/JTAlertView.h +++ b/JTAlertView/JTAlertView.h @@ -18,7 +18,7 @@ typedef NS_ENUM(NSInteger, JTAlertViewStyle) { JTAlertViewStyleDestructive }; -typedef void (^JTAlertViewStyling)(UIButton* btn); +typedef void (^JTAlertViewStyling)(UIButton *btn); // Public properties /** Size of the alertView. Default is 240.0, 290.0. */ @@ -56,7 +56,7 @@ typedef void (^JTAlertViewStyling)(UIButton* btn); - (void)addButtonWithTitle:(NSString *)titleText action:(void (^)(JTAlertView *alertView))action; - (void)addButtonWithTitle:(NSString *)titleText style:(JTAlertViewStyle)style action:(void (^)(JTAlertView *alertView))action; - (void)addButtonWithTitle:(NSString *)titleText style:(JTAlertViewStyle)style forControlEvents:(UIControlEvents)controlEvents action:(void (^)(JTAlertView *alertView))action; -- (void)addButtonWithTitle:(NSString *)titleText font:(UIFont * _Nullable )font style:(JTAlertViewStyle)style forControlEvents:(UIControlEvents)controlEvents action:(void (^)(JTAlertView *alertView))action; +- (void)addButtonWithTitle:(NSString *)titleText font:(UIFont * _Nullable)font style:(JTAlertViewStyle)style forControlEvents:(UIControlEvents)controlEvents action:(void (^)(JTAlertView *alertView))action; /** Designated method to adda a button. Provide a styling block to update custom styling to provided button, overriding default JTAlertViewStyle parameter and font. */ - (void)addButtonWithTitle:(NSString *)titleText styling:(JTAlertViewStyling _Nullable)styling forControlEvents:(UIControlEvents)controlEvents action:(void (^)(JTAlertView *alertView))action; diff --git a/JTAlertView/JTAlertView.m b/JTAlertView/JTAlertView.m index a6f5d34..c0155c0 100644 --- a/JTAlertView/JTAlertView.m +++ b/JTAlertView/JTAlertView.m @@ -88,7 +88,7 @@ - (void)addButtonWithTitle:(NSString *)titleText style:(JTAlertViewStyle)style f } - (void)addButtonWithTitle:(NSString *)titleText font:(UIFont *)font style:(JTAlertViewStyle)style forControlEvents:(UIControlEvents)controlEvents action:(void (^)(JTAlertView *alertView))action { - JTAlertViewStyling styling = ^(UIButton* btn) { + JTAlertViewStyling styling = ^(UIButton *btn) { [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; [btn setBackgroundColor:[UIColor whiteColor]]; if (!font) {