diff --git a/README.md b/README.md index 0447b1b..5e76f65 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,13 @@ An UIAlertView replacement with block syntax and fancy transition styles. As see ## Preview ![SIAlertView Screenshot](https://github.com/Sumi-Interactive/SIAlertView/raw/master/screenshot.png) +### Changed by Nododo +![SIAlertView ChangedByNododo](https://github.com/Nododo/SIAlertView/blob/master/SIAlertViewExample/SIAlertViewExample/SIAlertView.gif) ## Features +- 重新定义了messageLabel的对齐方式 (by Nododo) +- 根据message的高度决定messageLabel是否可以滑动 (by Nododo) - use window to present - happy with rotation - block syntax diff --git a/SIAlertView/SIAlertView.h b/SIAlertView/SIAlertView.h index e4d620a..bd20638 100644 --- a/SIAlertView/SIAlertView.h +++ b/SIAlertView/SIAlertView.h @@ -37,6 +37,12 @@ typedef NS_ENUM(NSInteger, SIAlertViewTransitionStyle) { SIAlertViewTransitionStyleDropDown }; +typedef NS_ENUM(NSInteger, SIAlertViewMessageAlignmentStyle) { + SIAlertViewMessageAlignmentStyleCenter = 0, + SIAlertViewMessageAlignmentStyleLeft, + SIAlertViewMessageAlignmentStyleRight +}; + @class SIAlertView; typedef void(^SIAlertViewHandler)(SIAlertView *alertView); @@ -48,6 +54,7 @@ typedef void(^SIAlertViewHandler)(SIAlertView *alertView); @property (nonatomic, assign) SIAlertViewTransitionStyle transitionStyle; // default is SIAlertViewTransitionStyleSlideFromBottom @property (nonatomic, assign) SIAlertViewBackgroundStyle backgroundStyle; // default is SIAlertViewBackgroundStyleGradient @property (nonatomic, assign) SIAlertViewButtonsListStyle buttonsListStyle; // default is SIAlertViewButtonsListStyleNormal +@property (nonatomic,assign) SIAlertViewMessageAlignmentStyle messageAlignmentStyle; // default is SIAlertViewMessageAlignmentCenter @property (nonatomic, copy) SIAlertViewHandler willShowHandler; @property (nonatomic, copy) SIAlertViewHandler didShowHandler; diff --git a/SIAlertView/SIAlertView.m b/SIAlertView/SIAlertView.m index 7a67df3..b8bbc50 100644 --- a/SIAlertView/SIAlertView.m +++ b/SIAlertView/SIAlertView.m @@ -18,7 +18,7 @@ #define DEBUG_LAYOUT 0 #define MESSAGE_MIN_LINE_COUNT 3 -#define MESSAGE_MAX_LINE_COUNT 5 +#define MESSAGE_CAN_SCROLL_COUNT 7 #define GAP 10 #define CANCEL_BUTTON_PADDING_TOP 5 #define CONTENT_PADDING_LEFT 10 @@ -49,6 +49,7 @@ @interface SIAlertView () @property (nonatomic, strong) UILabel *titleLabel; @property (nonatomic, strong) UILabel *messageLabel; +@property (nonatomic, strong) UIScrollView *messageScroll; @property (nonatomic, strong) UIView *containerView; @property (nonatomic, strong) NSMutableArray *buttons; @@ -251,19 +252,19 @@ + (void)initialize - (id)init { - return [self initWithTitle:nil andMessage:nil]; + return [self initWithTitle:nil andMessage:nil]; } - (id)initWithTitle:(NSString *)title andMessage:(NSString *)message { - self = [super init]; - if (self) { - _title = title; + self = [super init]; + if (self) { + _title = title; _message = message; _enabledParallaxEffect = YES; - self.items = [[NSMutableArray alloc] init]; - } - return self; + self.items = [[NSMutableArray alloc] init]; + } + return self; } #pragma mark - Class methods @@ -339,12 +340,12 @@ + (void)hideBackgroundAnimated:(BOOL)animated - (void)setTitle:(NSString *)title { _title = title; - [self invalidateLayout]; + [self invalidateLayout]; } - (void)setMessage:(NSString *)message { - _message = message; + _message = message; [self invalidateLayout]; } @@ -353,10 +354,10 @@ - (void)setMessage:(NSString *)message - (void)addButtonWithTitle:(NSString *)title type:(SIAlertViewButtonType)type handler:(SIAlertViewHandler)handler { SIAlertItem *item = [[SIAlertItem alloc] init]; - item.title = title; - item.type = type; - item.action = handler; - [self.items addObject:item]; + item.title = title; + item.type = type; + item.action = handler; + [self.items addObject:item]; } - (void)show @@ -372,7 +373,7 @@ - (void)show self.oldKeyWindow.tintAdjustmentMode = UIViewTintAdjustmentModeDimmed; } #endif - + if (![[SIAlertView sharedQueue] containsObject:self]) { [[SIAlertView sharedQueue] addObject:self]; } @@ -420,9 +421,9 @@ - (void)show self.didShowHandler(self); } [[NSNotificationCenter defaultCenter] postNotificationName:SIAlertViewDidShowNotification object:self userInfo:nil]; - #ifdef __IPHONE_7_0 +#ifdef __IPHONE_7_0 [self addParallaxEffect]; - #endif +#endif [SIAlertView setAnimating:NO]; @@ -447,9 +448,9 @@ - (void)dismissAnimated:(BOOL)animated cleanup:(BOOL)cleanup self.willDismissHandler(self); } [[NSNotificationCenter defaultCenter] postNotificationName:SIAlertViewWillDismissNotification object:self userInfo:nil]; - #ifdef __IPHONE_7_0 - [self removeParallaxEffect]; - #endif +#ifdef __IPHONE_7_0 + [self removeParallaxEffect]; +#endif } void (^dismissComplete)(void) = ^{ @@ -731,20 +732,28 @@ - (void)validateLayout self.containerView.layer.shadowPath = [UIBezierPath bezierPathWithRoundedRect:self.containerView.bounds cornerRadius:self.containerView.layer.cornerRadius].CGPath; CGFloat y = CONTENT_PADDING_TOP; - if (self.titleLabel) { + if (self.titleLabel) { self.titleLabel.text = self.title; CGFloat height = [self heightForTitleLabel]; self.titleLabel.frame = CGRectMake(CONTENT_PADDING_LEFT, y, self.containerView.bounds.size.width - CONTENT_PADDING_LEFT * 2, height); y += height; - } + } if (self.messageLabel) { if (y > CONTENT_PADDING_TOP) { y += GAP; } self.messageLabel.text = self.message; CGFloat height = [self heightForMessageLabel]; - self.messageLabel.frame = CGRectMake(CONTENT_PADDING_LEFT, y, self.containerView.bounds.size.width - CONTENT_PADDING_LEFT * 2, height); - y += height; + CGFloat defaultScrollHeight = MESSAGE_CAN_SCROLL_COUNT * self.messageLabel.font.lineHeight; + if (height <= defaultScrollHeight) { + self.messageLabel.frame = CGRectMake(CONTENT_PADDING_LEFT, y, self.containerView.bounds.size.width - CONTENT_PADDING_LEFT * 2, height); + y += height; + } else { + self.messageScroll.frame = CGRectMake(CONTENT_PADDING_LEFT, y, self.containerView.bounds.size.width - CONTENT_PADDING_LEFT * 2, defaultScrollHeight); + self.messageScroll.contentSize = CGSizeMake(self.containerView.bounds.size.width - CONTENT_PADDING_LEFT * 2, height); + self.messageLabel.frame = CGRectMake(0, 0, self.containerView.bounds.size.width - CONTENT_PADDING_LEFT * 2, height); + y += defaultScrollHeight; + } } if (self.items.count > 0) { if (y > CONTENT_PADDING_TOP) { @@ -775,15 +784,21 @@ - (void)validateLayout - (CGFloat)preferredHeight { - CGFloat height = CONTENT_PADDING_TOP; - if (self.title) { - height += [self heightForTitleLabel]; - } + CGFloat height = CONTENT_PADDING_TOP; + if (self.title) { + height += [self heightForTitleLabel]; + } if (self.message) { if (height > CONTENT_PADDING_TOP) { height += GAP; } - height += [self heightForMessageLabel]; + CGFloat tempHeight = [self heightForMessageLabel]; + CGFloat defaultScrollHeight = MESSAGE_CAN_SCROLL_COUNT * self.messageLabel.font.lineHeight; + if (tempHeight <= defaultScrollHeight) { + height += tempHeight; + } else { + height += defaultScrollHeight; + } } if (self.items.count > 0) { if (height > CONTENT_PADDING_TOP) { @@ -799,39 +814,39 @@ - (CGFloat)preferredHeight } } height += CONTENT_PADDING_BOTTOM; - return height; + return height; } - (CGFloat)heightForTitleLabel { if (self.titleLabel) { - #ifdef __IPHONE_7_0 - NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; - paragraphStyle.lineBreakMode = self.titleLabel.lineBreakMode; - - NSDictionary *attributes = @{NSFontAttributeName:self.titleLabel.font, - NSParagraphStyleAttributeName: paragraphStyle.copy}; - - // NSString class method: boundingRectWithSize:options:attributes:context is - // available only on ios7.0 sdk. - CGRect rect = [self.titleLabel.text boundingRectWithSize:CGSizeMake(CONTAINER_WIDTH - CONTENT_PADDING_LEFT * 2, CGFLOAT_MAX) - options:NSStringDrawingUsesLineFragmentOrigin - attributes:attributes - context:nil]; - return ceil(rect.size.height); - #else - CGSize size = [self.title sizeWithFont:self.titleLabel.font - minFontSize: - #if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_6_0 - self.titleLabel.font.pointSize * self.titleLabel.minimumScaleFactor - #else - self.titleLabel.minimumFontSize - #endif - actualFontSize:nil - forWidth:CONTAINER_WIDTH - CONTENT_PADDING_LEFT * 2 - lineBreakMode:self.titleLabel.lineBreakMode]; - return size.height; - #endif +#ifdef __IPHONE_7_0 + NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; + paragraphStyle.lineBreakMode = self.titleLabel.lineBreakMode; + + NSDictionary *attributes = @{NSFontAttributeName:self.titleLabel.font, + NSParagraphStyleAttributeName: paragraphStyle.copy}; + + // NSString class method: boundingRectWithSize:options:attributes:context is + // available only on ios7.0 sdk. + CGRect rect = [self.titleLabel.text boundingRectWithSize:CGSizeMake(CONTAINER_WIDTH - CONTENT_PADDING_LEFT * 2, CGFLOAT_MAX) + options:NSStringDrawingUsesLineFragmentOrigin + attributes:attributes + context:nil]; + return ceil(rect.size.height); +#else + CGSize size = [self.title sizeWithFont:self.titleLabel.font + minFontSize: +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_6_0 + self.titleLabel.font.pointSize * self.titleLabel.minimumScaleFactor +#else + self.titleLabel.minimumFontSize +#endif + actualFontSize:nil + forWidth:CONTAINER_WIDTH - CONTENT_PADDING_LEFT * 2 + lineBreakMode:self.titleLabel.lineBreakMode]; + return size.height; +#endif } return 0; @@ -841,30 +856,24 @@ - (CGFloat)heightForMessageLabel { CGFloat minHeight = MESSAGE_MIN_LINE_COUNT * self.messageLabel.font.lineHeight; if (self.messageLabel) { - CGFloat maxHeight = MESSAGE_MAX_LINE_COUNT * self.messageLabel.font.lineHeight; +#ifdef __IPHONE_7_0 + NSDictionary *attributes = @{NSFontAttributeName:self.messageLabel.font}; + // NSString class method: boundingRectWithSize:options:attributes:context is + // available only on ios7.0 sdk. + CGRect rect = [self.message boundingRectWithSize:CGSizeMake(CONTAINER_WIDTH - CONTENT_PADDING_LEFT * 2, CGFLOAT_MAX) + options:NSStringDrawingUsesLineFragmentOrigin + attributes:attributes + context:nil]; - #ifdef __IPHONE_7_0 - NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; - paragraphStyle.lineBreakMode = self.messageLabel.lineBreakMode; - - NSDictionary *attributes = @{NSFontAttributeName:self.messageLabel.font, - NSParagraphStyleAttributeName: paragraphStyle.copy}; - - // NSString class method: boundingRectWithSize:options:attributes:context is - // available only on ios7.0 sdk. - CGRect rect = [self.titleLabel.text boundingRectWithSize:CGSizeMake(CONTAINER_WIDTH - CONTENT_PADDING_LEFT * 2, maxHeight) - options:NSStringDrawingUsesLineFragmentOrigin - attributes:attributes - context:nil]; - - return MAX(minHeight, ceil(rect.size.height)); - #else - CGSize size = [self.message sizeWithFont:self.messageLabel.font - constrainedToSize:CGSizeMake(CONTAINER_WIDTH - CONTENT_PADDING_LEFT * 2, maxHeight) - lineBreakMode:self.messageLabel.lineBreakMode]; - - return MAX(minHeight, size.height); - #endif + return MAX(minHeight, ceil(rect.size.height)); + +#else + CGSize size = [self.message sizeWithFont:self.messageLabel.font + constrainedToSize:CGSizeMake(CONTAINER_WIDTH - CONTENT_PADDING_LEFT * 2, maxHeight) + lineBreakMode:self.messageLabel.lineBreakMode]; + + return MAX(minHeight, size.height); +#endif } return minHeight; @@ -906,12 +915,12 @@ - (void)setupContainerView - (void)updateTitleLabel { - if (self.title) { - if (!self.titleLabel) { - self.titleLabel = [[UILabel alloc] initWithFrame:self.bounds]; - self.titleLabel.textAlignment = NSTextAlignmentCenter; + if (self.title) { + if (!self.titleLabel) { + self.titleLabel = [[UILabel alloc] initWithFrame:self.bounds]; + self.titleLabel.textAlignment = NSTextAlignmentCenter; self.titleLabel.backgroundColor = [UIColor clearColor]; - self.titleLabel.font = self.titleFont; + self.titleLabel.font = self.titleFont; self.titleLabel.textColor = self.titleColor; self.titleLabel.adjustsFontSizeToFitWidth = YES; #if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_6_0 @@ -919,16 +928,16 @@ - (void)updateTitleLabel #else self.titleLabel.minimumFontSize = self.titleLabel.font.pointSize * 0.75; #endif - [self.containerView addSubview:self.titleLabel]; + [self.containerView addSubview:self.titleLabel]; #if DEBUG_LAYOUT self.titleLabel.backgroundColor = [UIColor redColor]; #endif - } - self.titleLabel.text = self.title; - } else { - [self.titleLabel removeFromSuperview]; - self.titleLabel = nil; - } + } + self.titleLabel.text = self.title; + } else { + [self.titleLabel removeFromSuperview]; + self.titleLabel = nil; + } [self invalidateLayout]; } @@ -937,13 +946,27 @@ - (void)updateMessageLabel if (self.message) { if (!self.messageLabel) { self.messageLabel = [[UILabel alloc] initWithFrame:self.bounds]; - self.messageLabel.textAlignment = NSTextAlignmentCenter; + self.messageLabel.textAlignment = (self.messageAlignmentStyle > 1) ? NSTextAlignmentRight : ((self.messageAlignmentStyle > 0) ? NSTextAlignmentLeft : NSTextAlignmentCenter); self.messageLabel.backgroundColor = [UIColor clearColor]; self.messageLabel.font = self.messageFont; self.messageLabel.textColor = self.messageColor; - self.messageLabel.numberOfLines = MESSAGE_MAX_LINE_COUNT; - [self.containerView addSubview:self.messageLabel]; + self.messageLabel.numberOfLines = 0; + CGFloat height = [self heightForMessageLabel]; + CGFloat defaultScrollHeight = MESSAGE_CAN_SCROLL_COUNT * self.messageLabel.font.lineHeight; + if (height <= defaultScrollHeight) { + [self.containerView addSubview:self.messageLabel]; + [self.messageScroll removeFromSuperview]; + self.messageScroll = nil; + } else { + if (!self.messageScroll) { + self.messageScroll = [[UIScrollView alloc] init]; + [self.containerView addSubview:self.messageScroll]; + [self.messageScroll addSubview:self.messageLabel]; + } + } + #if DEBUG_LAYOUT + self.messageScroll.backgroundColor = [UIColor blueColor]; self.messageLabel.backgroundColor = [UIColor redColor]; #endif } @@ -968,42 +991,42 @@ - (void)setupButtons - (UIButton *)buttonForItemIndex:(NSUInteger)index { SIAlertItem *item = self.items[index]; - UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; - button.tag = index; - button.autoresizingMask = UIViewAutoresizingFlexibleWidth; + UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; + button.tag = index; + button.autoresizingMask = UIViewAutoresizingFlexibleWidth; button.titleLabel.font = self.buttonFont; - [button setTitle:item.title forState:UIControlStateNormal]; - UIImage *normalImage = nil; - UIImage *highlightedImage = nil; - switch (item.type) { - case SIAlertViewButtonTypeCancel: - normalImage = [UIImage imageNamed:@"SIAlertView.bundle/button-cancel"]; - highlightedImage = [UIImage imageNamed:@"SIAlertView.bundle/button-cancel-d"]; - [button setTitleColor:self.cancelButtonColor forState:UIControlStateNormal]; + [button setTitle:item.title forState:UIControlStateNormal]; + UIImage *normalImage = nil; + UIImage *highlightedImage = nil; + switch (item.type) { + case SIAlertViewButtonTypeCancel: + normalImage = [UIImage imageNamed:@"SIAlertView.bundle/button-cancel"]; + highlightedImage = [UIImage imageNamed:@"SIAlertView.bundle/button-cancel-d"]; + [button setTitleColor:self.cancelButtonColor forState:UIControlStateNormal]; [button setTitleColor:[self.cancelButtonColor colorWithAlphaComponent:0.8] forState:UIControlStateHighlighted]; - break; - case SIAlertViewButtonTypeDestructive: - normalImage = [UIImage imageNamed:@"SIAlertView.bundle/button-destructive"]; - highlightedImage = [UIImage imageNamed:@"SIAlertView.bundle/button-destructive-d"]; + break; + case SIAlertViewButtonTypeDestructive: + normalImage = [UIImage imageNamed:@"SIAlertView.bundle/button-destructive"]; + highlightedImage = [UIImage imageNamed:@"SIAlertView.bundle/button-destructive-d"]; [button setTitleColor:self.destructiveButtonColor forState:UIControlStateNormal]; [button setTitleColor:[self.destructiveButtonColor colorWithAlphaComponent:0.8] forState:UIControlStateHighlighted]; - break; - case SIAlertViewButtonTypeDefault: - default: - normalImage = [UIImage imageNamed:@"SIAlertView.bundle/button-default"]; - highlightedImage = [UIImage imageNamed:@"SIAlertView.bundle/button-default-d"]; - [button setTitleColor:self.buttonColor forState:UIControlStateNormal]; + break; + case SIAlertViewButtonTypeDefault: + default: + normalImage = [UIImage imageNamed:@"SIAlertView.bundle/button-default"]; + highlightedImage = [UIImage imageNamed:@"SIAlertView.bundle/button-default-d"]; + [button setTitleColor:self.buttonColor forState:UIControlStateNormal]; [button setTitleColor:[self.buttonColor colorWithAlphaComponent:0.8] forState:UIControlStateHighlighted]; - break; - } - CGFloat hInset = floorf(normalImage.size.width / 2); - CGFloat vInset = floorf(normalImage.size.height / 2); - UIEdgeInsets insets = UIEdgeInsetsMake(vInset, hInset, vInset, hInset); - normalImage = [normalImage resizableImageWithCapInsets:insets]; - highlightedImage = [highlightedImage resizableImageWithCapInsets:insets]; - [button setBackgroundImage:normalImage forState:UIControlStateNormal]; - [button setBackgroundImage:highlightedImage forState:UIControlStateHighlighted]; - [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside]; + break; + } + CGFloat hInset = floorf(normalImage.size.width / 2); + CGFloat vInset = floorf(normalImage.size.height / 2); + UIEdgeInsets insets = UIEdgeInsetsMake(vInset, hInset, vInset, hInset); + normalImage = [normalImage resizableImageWithCapInsets:insets]; + highlightedImage = [highlightedImage resizableImageWithCapInsets:insets]; + [button setBackgroundImage:normalImage forState:UIControlStateNormal]; + [button setBackgroundImage:highlightedImage forState:UIControlStateHighlighted]; + [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside]; return button; } @@ -1012,12 +1035,12 @@ - (UIButton *)buttonForItemIndex:(NSUInteger)index - (void)buttonAction:(UIButton *)button { - [SIAlertView setAnimating:YES]; // set this flag to YES in order to prevent showing another alert in action block + [SIAlertView setAnimating:YES]; // set this flag to YES in order to prevent showing another alert in action block SIAlertItem *item = self.items[button.tag]; - if (item.action) { - item.action(self); - } - [self dismissAnimated:YES]; + if (item.action) { + item.action(self); + } + [self dismissAnimated:YES]; } #pragma mark - CAAnimation delegate diff --git a/SIAlertViewExample/SIAlertViewExample.xcodeproj/project.pbxproj b/SIAlertViewExample/SIAlertViewExample.xcodeproj/project.pbxproj index d318b91..401803b 100644 --- a/SIAlertViewExample/SIAlertViewExample.xcodeproj/project.pbxproj +++ b/SIAlertViewExample/SIAlertViewExample.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 1F44C1501CFFD7A800DE60B4 /* SIAlertView.gif in Resources */ = {isa = PBXBuildFile; fileRef = 1F44C14F1CFFD7A800DE60B4 /* SIAlertView.gif */; }; 72AD5C9217BD1B7200A85539 /* button-cancel-d.png in Resources */ = {isa = PBXBuildFile; fileRef = 72AD5C8617BD1B7200A85539 /* button-cancel-d.png */; }; 72AD5C9317BD1B7200A85539 /* button-cancel-d@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 72AD5C8717BD1B7200A85539 /* button-cancel-d@2x.png */; }; 72AD5C9417BD1B7200A85539 /* button-cancel.png in Resources */ = {isa = PBXBuildFile; fileRef = 72AD5C8817BD1B7200A85539 /* button-cancel.png */; }; @@ -42,6 +43,7 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 1F44C14F1CFFD7A800DE60B4 /* SIAlertView.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = SIAlertView.gif; sourceTree = ""; }; 72AD5C8617BD1B7200A85539 /* button-cancel-d.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "button-cancel-d.png"; sourceTree = ""; }; 72AD5C8717BD1B7200A85539 /* button-cancel-d@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "button-cancel-d@2x.png"; sourceTree = ""; }; 72AD5C8817BD1B7200A85539 /* button-cancel.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "button-cancel.png"; sourceTree = ""; }; @@ -168,6 +170,7 @@ 7E23C68417325EAA00784CF1 /* Default.png */, 7E23C68617325EAA00784CF1 /* Default@2x.png */, 7E23C68817325EAB00784CF1 /* Default-568h@2x.png */, + 1F44C14F1CFFD7A800DE60B4 /* SIAlertView.gif */, ); name = "Supporting Files"; sourceTree = ""; @@ -270,6 +273,7 @@ files = ( 7E23C67D17325EAA00784CF1 /* InfoPlist.strings in Resources */, 7E23C68517325EAA00784CF1 /* Default.png in Resources */, + 1F44C1501CFFD7A800DE60B4 /* SIAlertView.gif in Resources */, 7E23C68717325EAA00784CF1 /* Default@2x.png in Resources */, 7E23C68917325EAB00784CF1 /* Default-568h@2x.png in Resources */, 7E23C68C17325EAB00784CF1 /* MainStoryboard_iPhone.storyboard in Resources */, diff --git a/SIAlertViewExample/SIAlertViewExample/SIAlertView.gif b/SIAlertViewExample/SIAlertViewExample/SIAlertView.gif new file mode 100644 index 0000000..2d46908 Binary files /dev/null and b/SIAlertViewExample/SIAlertViewExample/SIAlertView.gif differ diff --git a/SIAlertViewExample/SIAlertViewExample/ViewController.m b/SIAlertViewExample/SIAlertViewExample/ViewController.m index ec2687e..fe3f987 100644 --- a/SIAlertViewExample/SIAlertViewExample/ViewController.m +++ b/SIAlertViewExample/SIAlertViewExample/ViewController.m @@ -45,7 +45,7 @@ - (void)viewDidLoad - (IBAction)alert1:(id)sender { - SIAlertView *alertView = [[SIAlertView alloc] initWithTitle:@"Title1" andMessage:@"Count down"]; + SIAlertView *alertView = [[SIAlertView alloc] initWithTitle:@"Title1" andMessage:@"Count downCount downCount downCount downCount downCount downCount downCount downCount downCount downCount downCount downCount downCount downCount downCount downCount downCount downCount downCount downCount downCount downCount downCount downCount downCount downCount downCount downCount downCount downCount downCount downCount downCount downCount down"]; [alertView addButtonWithTitle:@"Button1" type:SIAlertViewButtonTypeDefault handler:^(SIAlertView *alertView) { @@ -74,6 +74,7 @@ - (IBAction)alert1:(id)sender alertView.didDismissHandler = ^(SIAlertView *alertView) { NSLog(@"%@, didDismissHandler", alertView); }; + alertView.messageAlignmentStyle = SIAlertViewMessageAlignmentStyleLeft; // alertView.cornerRadius = 4; // alertView.buttonFont = [UIFont boldSystemFontOfSize:12]; @@ -203,7 +204,7 @@ - (IBAction)alert3:(id)sender observer1 = observer2 = observer3 = observer4 = nil; }]; - + alertView.messageAlignmentStyle = SIAlertViewMessageAlignmentStyleRight; [alertView show]; }