├── .gitignore ├── CXAlertView.podspec ├── CXAlertView ├── CXAlertButtonContainerView.h ├── CXAlertButtonContainerView.m ├── CXAlertButtonItem.h ├── CXAlertButtonItem.m ├── CXAlertView.h ├── CXAlertView.m ├── CXAlertViewController.h ├── CXAlertViewController.m ├── CXBlurView.h └── CXBlurView.m ├── CXAlertViewDemo ├── CXAlertViewDemo.xcodeproj │ └── project.pbxproj └── CXAlertViewDemo │ ├── CXAlertViewDemo-Info.plist │ ├── CXAlertViewDemo-Prefix.pch │ ├── CXAppDelegate.h │ ├── CXAppDelegate.m │ ├── CXViewController.h │ ├── CXViewController.m │ ├── Default-568h@2x.png │ ├── Default.png │ ├── Default@2x.png │ ├── bkg.png │ ├── bkg2.jpg │ ├── en.lproj │ ├── CXViewController.xib │ └── InfoPlist.strings │ ├── main.m │ └── taipei101.jpg ├── LICENSE ├── README.md ├── screenshot-multilined-buttons.png ├── screenshot1.png └── screenshot2.png /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | .DS_Store 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | *.xcworkspace 13 | !default.xcworkspace 14 | xcuserdata 15 | profile 16 | *.moved-aside 17 | DerivedData 18 | .idea/ 19 | -------------------------------------------------------------------------------- /CXAlertView.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod spec lint CXAlertView.podspec' to ensure this is a 3 | # valid spec and to remove all comments including this before submitting the spec. 4 | # 5 | # To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html 6 | # To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/ 7 | # 8 | 9 | Pod::Spec.new do |s| 10 | 11 | # ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 12 | # 13 | # These will help people to find your library, and whilst it 14 | # can feel like a chore to fill in it's definitely to your advantage. The 15 | # summary should be tweet-length, and the description more in depth. 16 | # 17 | 18 | s.name = "CXAlertView" 19 | s.version = "1.1.0" 20 | s.summary = "Custom alert-view which allow you to add view as main content." 21 | 22 | s.description = <<-DESC 23 | A longer description of CXAlertView in Markdown format. 24 | 25 | * Think: Why did you write this? What is the focus? What does it do? 26 | * CocoaPods will be using this to generate tags, and improve search results. 27 | * Try to keep it short, snappy and to the point. 28 | * Finally, don't worry about the indent, CocoaPods strips it! 29 | DESC 30 | 31 | s.homepage = "https://github.com/ChrisXu1221/CXAlertView" 32 | # s.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif" 33 | 34 | 35 | # ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 36 | # 37 | # Licensing your code is important. See http://choosealicense.com for more info. 38 | # CocoaPods will detect a license file if there is a named LICENSE* 39 | # Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'. 40 | # 41 | 42 | s.license = "MIT" 43 | # s.license = { :type => "MIT", :file => "FILE_LICENSE" } 44 | 45 | 46 | # ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 47 | # 48 | # Specify the authors of the library, with email addresses. Email addresses 49 | # of the authors are extracted from the SCM log. E.g. $ git log. CocoaPods also 50 | # accepts just a name if you'd rather not provide an email address. 51 | # 52 | # Specify a social_media_url where others can refer to, for example a twitter 53 | # profile URL. 54 | # 55 | 56 | s.author = { "Chris Xu" => "taterctl@gmail.com" } 57 | # Or just: s.author = "Chris Xu" 58 | # s.authors = { "Chris Xu" => "taterctl@gmail.com" } 59 | # s.social_media_url = "http://twitter.com/Chris Xu" 60 | 61 | # ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 62 | # 63 | # If this Pod runs only on iOS or OS X, then specify the platform and 64 | # the deployment target. You can optionally include the target after the platform. 65 | # 66 | 67 | # s.platform = :ios 68 | s.platform = :ios, "5.0" 69 | 70 | # When using multiple platforms 71 | # s.ios.deployment_target = "5.0" 72 | # s.osx.deployment_target = "10.7" 73 | 74 | 75 | # ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 76 | # 77 | # Specify the location from where the source should be retrieved. 78 | # Supports git, hg, bzr, svn and HTTP. 79 | # 80 | 81 | s.source = { :git => "https://github.com/ChrisXu1221/CXAlertView.git", :tag => "1.1.0" } 82 | 83 | 84 | # ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 85 | # 86 | # CocoaPods is smart about how it includes source code. For source files 87 | # giving a folder will include any h, m, mm, c & cpp files. For header 88 | # files it will include any header in the folder. 89 | # Not including the public_header_files will make all headers public. 90 | # 91 | 92 | s.source_files = 'CXAlertView/*.{h,m}' 93 | s.exclude_files = "Classes/Exclude" 94 | 95 | # s.public_header_files = "Classes/**/*.h" 96 | 97 | 98 | # ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 99 | # 100 | # A list of resources included with the Pod. These are copied into the 101 | # target bundle with a build phase script. Anything else will be cleaned. 102 | # You can preserve files from being cleaned, please don't preserve 103 | # non-essential files like tests, examples and documentation. 104 | # 105 | 106 | # s.resource = "icon.png" 107 | # s.resources = "Resources/*.png" 108 | 109 | # s.preserve_paths = "FilesToSave", "MoreFilesToSave" 110 | 111 | 112 | # ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 113 | # 114 | # Link your library with frameworks, or libraries. Libraries do not include 115 | # the lib prefix of their name. 116 | # 117 | 118 | # s.framework = "SomeFramework" 119 | s.framework = 'QuartzCore', 'CoreGraphics', 'Accelerate' 120 | 121 | # s.library = "iconv" 122 | # s.libraries = "iconv", "xml2" 123 | 124 | 125 | # ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 126 | # 127 | # If your library depends on compiler flags you can set them in the xcconfig hash 128 | # where they will only apply to your library. If you depend on other Podspecs 129 | # you can include multiple dependencies to ensure it works. 130 | 131 | s.requires_arc = true 132 | 133 | # s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" } 134 | # s.dependency "JSONKit", "~> 1.4" 135 | 136 | end 137 | -------------------------------------------------------------------------------- /CXAlertView/CXAlertButtonContainerView.h: -------------------------------------------------------------------------------- 1 | // 2 | // CXAlertButtonContainerView.h 3 | // CXAlertViewDemo 4 | // 5 | // Created by ChrisXu on 13/9/25. 6 | // Copyright (c) 2013年 ChrisXu. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "CXAlertView.h" 11 | 12 | @interface CXAlertButtonContainerView : UIScrollView 13 | 14 | @property (nonatomic, strong) NSMutableArray *buttons; 15 | @property (nonatomic) BOOL defaultTopLineVisible; 16 | 17 | - (void)addButtonWithTitle:(NSString *)title type:(CXAlertViewButtonType)type handler:(CXAlertButtonHandler)handler; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /CXAlertView/CXAlertButtonContainerView.m: -------------------------------------------------------------------------------- 1 | // 2 | // CXAlertButtonContainerView.m 3 | // CXAlertViewDemo 4 | // 5 | // Created by ChrisXu on 13/9/25. 6 | // Copyright (c) 2013年 ChrisXu. All rights reserved. 7 | // 8 | 9 | #import "CXAlertButtonContainerView.h" 10 | 11 | @interface CXAlertButtonContainerView () 12 | 13 | @end 14 | 15 | @implementation CXAlertButtonContainerView 16 | 17 | - (id)initWithFrame:(CGRect)frame 18 | { 19 | self = [super initWithFrame:frame]; 20 | if (self) { 21 | // Initialization code 22 | _buttons = [[NSMutableArray alloc] init]; 23 | } 24 | return self; 25 | } 26 | 27 | - (id)init 28 | { 29 | self = [super init]; 30 | if (self) { 31 | _buttons = [[NSMutableArray alloc] init]; 32 | } 33 | 34 | return self; 35 | } 36 | 37 | - (void)drawRect:(CGRect)rect 38 | { 39 | [super drawRect:rect]; 40 | 41 | if (_defaultTopLineVisible) { 42 | CGContextRef context = UIGraphicsGetCurrentContext(); 43 | CGContextClearRect(context, self.bounds); 44 | 45 | CGContextSetStrokeColorWithColor(context, [UIColor colorWithRed:0.671 green:0.675 blue:0.694 alpha:1.000].CGColor); 46 | CGContextSetLineWidth(context, 1.0); 47 | CGContextMoveToPoint(context, 0,0); 48 | CGContextAddLineToPoint(context, CGRectGetWidth(self.frame), 0); 49 | CGContextStrokePath(context); 50 | } 51 | } 52 | 53 | - (void)layoutSubviews 54 | { 55 | [super layoutSubviews]; 56 | } 57 | 58 | - (BOOL)touchesShouldCancelInContentView:(UIView *)view { 59 | return YES; 60 | } 61 | #pragma mark - PB 62 | - (void)addButtonWithTitle:(NSString *)title type:(CXAlertViewButtonType)type handler:(CXAlertButtonHandler)handler 63 | { 64 | 65 | } 66 | 67 | #pragma mark - PV 68 | 69 | @end 70 | -------------------------------------------------------------------------------- /CXAlertView/CXAlertButtonItem.h: -------------------------------------------------------------------------------- 1 | // 2 | // CXAlertItem.h 3 | // CXAlertViewDemo 4 | // 5 | // Created by ChrisXu on 13/9/12. 6 | // Copyright (c) 2013年 ChrisXu. All rights reserved. 7 | // 8 | 9 | #import 10 | //#import "CXAlertView.h" 11 | typedef NS_ENUM(NSInteger, CXAlertViewButtonType) { 12 | CXAlertViewButtonTypeDefault = 0, 13 | CXAlertViewButtonTypeCustom = 1, 14 | CXAlertViewButtonTypeCancel = 2 15 | }; 16 | 17 | @class CXAlertView; 18 | @class CXAlertButtonItem; 19 | typedef void(^CXAlertButtonHandler)(CXAlertView *alertView, CXAlertButtonItem *button); 20 | 21 | @interface CXAlertButtonItem : UIButton 22 | 23 | 24 | @property (nonatomic, copy) NSString *title; 25 | @property (nonatomic, assign) CXAlertViewButtonType type; 26 | @property (nonatomic, copy) CXAlertButtonHandler action; 27 | @property (nonatomic) BOOL defaultRightLineVisible; 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /CXAlertView/CXAlertButtonItem.m: -------------------------------------------------------------------------------- 1 | // 2 | // CXAlertItem.m 3 | // CXAlertViewDemo 4 | // 5 | // Created by ChrisXu on 13/9/12. 6 | // Copyright (c) 2013年 ChrisXu. All rights reserved. 7 | // 8 | 9 | #import "CXAlertButtonItem.h" 10 | 11 | @implementation CXAlertButtonItem 12 | 13 | - (id)initWithFrame:(CGRect)frame 14 | { 15 | self = [super initWithFrame:frame]; 16 | if (self) { 17 | // Initialization code 18 | 19 | } 20 | return self; 21 | } 22 | 23 | - (void)setHighlighted:(BOOL)highlighted 24 | { 25 | [super setHighlighted:highlighted]; 26 | 27 | if (highlighted) { 28 | self.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0.3]; 29 | } 30 | else { 31 | self.backgroundColor = [UIColor clearColor]; 32 | } 33 | } 34 | 35 | - (void)drawRect:(CGRect)rect 36 | { 37 | if (_defaultRightLineVisible) { 38 | CGContextRef context = UIGraphicsGetCurrentContext(); 39 | CGContextClearRect(context, self.bounds); 40 | 41 | CGContextSetStrokeColorWithColor(context, [UIColor colorWithRed:0.671 green:0.675 blue:0.694 alpha:1.000].CGColor); 42 | CGContextSetLineWidth(context, 1.0); 43 | CGContextMoveToPoint(context, CGRectGetWidth(self.frame),0); 44 | CGContextAddLineToPoint(context, CGRectGetWidth(self.frame), CGRectGetHeight(self.frame)); 45 | CGContextStrokePath(context); 46 | } 47 | } 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /CXAlertView/CXAlertView.h: -------------------------------------------------------------------------------- 1 | // 2 | // CXAlertView.h 3 | // CXAlertViewDemo 4 | // 5 | // Created by ChrisXu on 13/9/12. 6 | // Copyright (c) 2013年 ChrisXu. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "CXAlertButtonItem.h" 11 | 12 | @class CXAlertView; 13 | typedef void(^CXAlertViewHandler)(CXAlertView *alertView); 14 | @interface CXAlertView : UIView 15 | 16 | @property (nonatomic, copy) NSString *title; 17 | @property (nonatomic, copy) UIView *contentView; 18 | @property (nonatomic, strong, readonly) NSMutableArray *buttons; 19 | 20 | @property (nonatomic, copy) CXAlertViewHandler willShowHandler; 21 | @property (nonatomic, copy) CXAlertViewHandler didShowHandler; 22 | @property (nonatomic, copy) CXAlertViewHandler willDismissHandler; 23 | @property (nonatomic, copy) CXAlertViewHandler didDismissHandler; 24 | 25 | @property (nonatomic, readonly, getter = isVisible) BOOL visible; 26 | 27 | @property (nonatomic, strong) UIColor *viewBackgroundColor NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR; 28 | @property (nonatomic, strong) UIColor *titleColor NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR; 29 | @property (nonatomic, strong) UIFont *titleFont NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR; 30 | @property (nonatomic, strong) UIFont *buttonFont NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR; 31 | @property (nonatomic, strong) UIColor *buttonColor NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR; 32 | @property (nonatomic, strong) UIColor *cancelButtonColor NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR; 33 | @property (nonatomic, strong) UIFont *cancelButtonFont NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR; // default [UIFont boldSystemFontOfSize:18.] 34 | @property (nonatomic, strong) UIColor *customButtonColor NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR; 35 | @property (nonatomic, strong) UIFont *customButtonFont NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR; // default [UIFont systemFontOfSize:18.] 36 | @property (nonatomic, assign) CGFloat cornerRadius NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR; // default is 8.0 37 | @property (nonatomic, assign) CGFloat shadowRadius NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR; // default is 8.0 38 | 39 | @property (nonatomic, assign) CGFloat scrollViewPadding; 40 | @property (nonatomic, assign) CGFloat buttonHeight; 41 | @property (nonatomic, assign) CGFloat containerWidth; 42 | @property (nonatomic, assign) CGFloat vericalPadding; 43 | @property (nonatomic, assign) CGFloat topScrollViewMaxHeight; 44 | @property (nonatomic, assign) CGFloat topScrollViewMinHeight; 45 | @property (nonatomic, assign) CGFloat contentScrollViewMaxHeight; 46 | @property (nonatomic, assign) CGFloat contentScrollViewMinHeight; 47 | @property (nonatomic, assign) CGFloat bottomScrollViewHeight; 48 | @property (nonatomic, assign) BOOL showButtonLine; 49 | @property (nonatomic, assign) BOOL showBlurBackground; 50 | // Create 51 | - (id)initWithTitle:(NSString *)title message:(NSString *)message cancelButtonTitle:(NSString *)cancelButtonTitle; 52 | - (id)initWithTitle:(NSString *)title contentView:(UIView *)contentView cancelButtonTitle:(NSString *)cancelButtonTitle; 53 | // Buttons 54 | - (void)addButtonWithTitle:(NSString *)title type:(CXAlertViewButtonType)type handler:(CXAlertButtonHandler)handler; 55 | - (void)setDefaultButtonImage:(UIImage *)defaultButtonImage forState:(UIControlState)state NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR; 56 | - (void)setCancelButtonImage:(UIImage *)cancelButtonImage forState:(UIControlState)state NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR; 57 | - (void)setCustomButtonImage:(UIImage *)customButtonImage forState:(UIControlState)state NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR; 58 | // AlertView action 59 | - (void)show; 60 | - (void)dismiss; 61 | - (void)shake; 62 | // Operation 63 | - (void)cleanAllPenddingAlert; 64 | @end 65 | -------------------------------------------------------------------------------- /CXAlertView/CXAlertView.m: -------------------------------------------------------------------------------- 1 | // 2 | // CXAlertView.m 3 | // CXAlertViewDemo 4 | // 5 | // Created by ChrisXu on 13/9/12. 6 | // Copyright (c) 2013年 ChrisXu. All rights reserved. 7 | // 8 | 9 | #import "CXAlertView.h" 10 | #import "CXAlertButtonItem.h" 11 | #import "CXAlertViewController.h" 12 | #import "CXAlertButtonContainerView.h" 13 | #import "CXBlurView.h" 14 | #import 15 | 16 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_6_0 17 | #define LBM NSLineBreakByTruncatingTail 18 | #define BT_LBM NSLineBreakByWordWrapping 19 | #define TA_CENTER NSTextAlignmentCenter 20 | #else 21 | #define LBM UILineBreakModeTailTruncation 22 | #define BT_LBM UILineBreakModeWordWrap 23 | #define TA_CENTER UITextAlignmentCenter 24 | #endif 25 | 26 | static CGFloat const kDefaultScrollViewPadding = 10.; 27 | static CGFloat const kDefaultButtonHeight = 44.; 28 | static CGFloat const kDefaultNoButtonHeight = 0.; 29 | static CGFloat const kDefaultContainerWidth = 280.; 30 | static CGFloat const kDefaultVericalPadding = 10.; 31 | static CGFloat const kDefaultTopScrollViewMaxHeight = 50.; 32 | static CGFloat const kDefaultTopScrollViewMinHeight = 10.; 33 | static CGFloat const kDefaultContentScrollViewMaxHeight = 180.; 34 | static CGFloat const kDefaultContentScrollViewMinHeight = 0.; 35 | static CGFloat const kDefaultBottomScrollViewHeight = 44.; 36 | 37 | //#define BOTTOM_MIN_HEIGHT 44 38 | 39 | @class CXAlertButtonItem; 40 | @class CXAlertViewController; 41 | @class CXAlertBackgroundWindow; 42 | 43 | static NSMutableArray *__cx_pending_alert_queue; 44 | static BOOL __cx_alert_animating; 45 | static CXAlertBackgroundWindow *__cx_alert_background_window; 46 | static CXAlertView *__cx_alert_current_view; 47 | static BOOL __cx_statsu_prefersStatusBarHidden; 48 | 49 | @interface CXTempViewController : UIViewController 50 | 51 | @end 52 | 53 | @implementation CXTempViewController 54 | 55 | - (BOOL)prefersStatusBarHidden 56 | { 57 | return __cx_statsu_prefersStatusBarHidden; 58 | } 59 | 60 | @end 61 | 62 | @interface CXAlertBackgroundWindow : UIWindow 63 | 64 | @end 65 | 66 | @implementation CXAlertBackgroundWindow 67 | 68 | - (id)initWithFrame:(CGRect)frame 69 | { 70 | self = [super initWithFrame:frame]; 71 | if (self) { 72 | self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 73 | self.opaque = NO; 74 | self.windowLevel = UIWindowLevelAlert - 1; 75 | self.rootViewController = [[CXTempViewController alloc] init]; 76 | self.rootViewController.view.backgroundColor = [UIColor clearColor]; 77 | } 78 | return self; 79 | } 80 | 81 | - (void)drawRect:(CGRect)rect 82 | { 83 | CGContextRef context = UIGraphicsGetCurrentContext(); 84 | [[UIColor colorWithWhite:0 alpha:0.5] set]; 85 | CGContextFillRect(context, self.bounds); 86 | } 87 | 88 | @end 89 | 90 | @interface CXAlertView () 91 | { 92 | BOOL _updateAnimated; 93 | NSString *_cancelButtonTitle; 94 | CGFloat _maxButtonHeight; 95 | } 96 | 97 | @property (nonatomic, strong) UIWindow *oldKeyWindow; 98 | @property (nonatomic, strong) UIWindow *alertWindow; 99 | @property (nonatomic, assign, getter = isVisible) BOOL visible; 100 | 101 | @property (nonatomic, strong) UIScrollView *topScrollView; 102 | @property (nonatomic, strong) UIScrollView *contentScrollView; 103 | @property (nonatomic, strong) CXAlertButtonContainerView *bottomScrollView; 104 | 105 | @property (nonatomic, strong) UILabel *titleLabel; 106 | @property (nonatomic, strong) UIView *containerView; 107 | @property (nonatomic, strong) CXBlurView *blurView; 108 | 109 | @property (nonatomic, assign, getter = isLayoutDirty) BOOL layoutDirty; 110 | 111 | + (NSMutableArray *)sharedQueue; 112 | + (CXAlertView *)currentAlertView; 113 | 114 | + (BOOL)isAnimating; 115 | + (void)setAnimating:(BOOL)animating; 116 | 117 | + (void)showBackground; 118 | + (void)hideBackgroundAnimated:(BOOL)animated; 119 | // Height 120 | - (CGFloat)heightWithText:(NSString *)text font:(UIFont *)font; 121 | - (CGFloat)preferredHeight; 122 | - (CGFloat)heightForTopScrollView; 123 | - (CGFloat)heightForContentScrollView; 124 | - (CGFloat)heightForBottomScrollView; 125 | // 126 | - (void)setup; 127 | - (void)tearDown; 128 | - (void)validateLayout; 129 | - (void)invalidateLayout; 130 | - (void)resetTransition; 131 | // Views 132 | - (void)setupContainerView; 133 | - (void)setupScrollViews; 134 | - (void)updateTopScrollView; 135 | - (void)updateContentScrollView; 136 | - (void)updateBottomScrollView; 137 | - (void)dismissWithCleanup:(BOOL)cleanup; 138 | //transition 139 | - (void)transitionInCompletion:(void(^)(void))completion; 140 | - (void)transitionOutCompletion:(void(^)(void))completion; 141 | 142 | // Buttons 143 | - (UIFont*)fontForButtonType:(CXAlertViewButtonType)type; 144 | - (CGRect)frameWithButtonTitile:(NSString *)title type:(CXAlertViewButtonType)type; 145 | - (void)addButtonWithTitle:(NSString *)title type:(CXAlertViewButtonType)type handler:(CXAlertButtonHandler)handler font:(UIFont *)font; 146 | - (CXAlertButtonItem *)buttonItemWithType:(CXAlertViewButtonType)type font:(UIFont *)font; 147 | - (void)buttonAction:(CXAlertButtonItem *)buttonItem; 148 | - (void)setButtonImage:(UIImage *)image forState:(UIControlState)state andButtonType:(CXAlertViewButtonType)type; 149 | - (void)updateAllButtonsFont; 150 | 151 | // Blur 152 | - (void)updateBlurBackground; 153 | @end 154 | 155 | @implementation CXAlertView 156 | 157 | + (void)initialize 158 | { 159 | if (self != [CXAlertView class]) 160 | return; 161 | 162 | static dispatch_once_t onceToken; 163 | dispatch_once(&onceToken, ^ { 164 | CXAlertView *appearance = [self appearance]; 165 | appearance.viewBackgroundColor = [UIColor whiteColor]; 166 | appearance.titleColor = [UIColor blackColor]; 167 | appearance.titleFont = [UIFont boldSystemFontOfSize:20]; 168 | appearance.buttonFont = [UIFont systemFontOfSize:[UIFont buttonFontSize]]; 169 | appearance.buttonColor = [UIColor colorWithRed:0.0f green:0.5f blue:1.0f alpha:1.0f]; 170 | appearance.cancelButtonColor = [UIColor colorWithRed:0.0f green:0.5f blue:1.0f alpha:1.0f]; 171 | appearance.cancelButtonFont = [UIFont boldSystemFontOfSize:18.]; 172 | appearance.customButtonColor = [UIColor colorWithRed:0.075f green:0.6f blue:0.9f alpha:1.0f]; 173 | appearance.customButtonFont = [UIFont systemFontOfSize:18.]; 174 | appearance.cornerRadius = 8; 175 | appearance.shadowRadius = 8; 176 | }); 177 | } 178 | 179 | - (id)initWithFrame:(CGRect)frame 180 | { 181 | self = [super initWithFrame:frame]; 182 | if (self) { 183 | // Initialization code 184 | } 185 | return self; 186 | } 187 | 188 | - (void)layoutSubviews 189 | { 190 | [super layoutSubviews]; 191 | [self validateLayout]; 192 | } 193 | #pragma mark - CXAlertView PB 194 | // Create 195 | - (id)initWithTitle:(NSString *)title message:(NSString *)message cancelButtonTitle:(NSString *)cancelButtonTitle 196 | { 197 | _vericalPadding = kDefaultVericalPadding; 198 | _containerWidth = kDefaultContainerWidth; 199 | 200 | UILabel *messageLabel = [[UILabel alloc] init]; 201 | messageLabel.textAlignment = NSTextAlignmentCenter; 202 | messageLabel.backgroundColor = [UIColor clearColor]; 203 | messageLabel.font = [UIFont systemFontOfSize:14.0]; 204 | messageLabel.textColor = [UIColor blackColor]; 205 | messageLabel.numberOfLines = 0; 206 | messageLabel.text = message; 207 | messageLabel.frame = CGRectMake( self.vericalPadding, 0, self.containerWidth - self.vericalPadding*2, [self heightWithText:message font:messageLabel.font]); 208 | 209 | messageLabel.lineBreakMode=LBM; 210 | 211 | return [self initWithTitle:title contentView:messageLabel cancelButtonTitle:cancelButtonTitle]; 212 | } 213 | 214 | - (id)initWithTitle:(NSString *)title contentView:(UIView *)contentView cancelButtonTitle:(NSString *)cancelButtonTitle 215 | { 216 | self = [super init]; 217 | if (self) { 218 | _buttons = [[NSMutableArray alloc] init]; 219 | _title = title; 220 | _contentView = contentView; 221 | _scrollViewPadding = kDefaultScrollViewPadding; 222 | if (cancelButtonTitle) { 223 | self.buttonHeight = kDefaultButtonHeight; 224 | _bottomScrollViewHeight = kDefaultBottomScrollViewHeight; 225 | _showButtonLine = YES; 226 | }else{ 227 | self.buttonHeight = kDefaultNoButtonHeight; 228 | _bottomScrollViewHeight = kDefaultNoButtonHeight; 229 | } 230 | 231 | _containerWidth = kDefaultContainerWidth; 232 | _vericalPadding = kDefaultVericalPadding; 233 | _topScrollViewMaxHeight = kDefaultTopScrollViewMaxHeight; 234 | _topScrollViewMinHeight = kDefaultTopScrollViewMinHeight; 235 | _contentScrollViewMaxHeight = kDefaultContentScrollViewMaxHeight; 236 | _contentScrollViewMinHeight = kDefaultContentScrollViewMinHeight; 237 | 238 | _buttonFont=[UIFont systemFontOfSize:[UIFont buttonFontSize]]; 239 | _cancelButtonFont = [UIFont boldSystemFontOfSize:[UIFont buttonFontSize]]; 240 | _customButtonFont=_buttonFont; 241 | 242 | _showButtonLine = YES; 243 | _showBlurBackground = YES; 244 | [self setupScrollViews]; 245 | if (cancelButtonTitle) { 246 | [self addButtonWithTitle:cancelButtonTitle type:CXAlertViewButtonTypeCancel handler:^(CXAlertView *alertView, CXAlertButtonItem *button) { 247 | [alertView dismiss]; 248 | }]; 249 | } 250 | } 251 | return self; 252 | } 253 | 254 | // Buttons 255 | - (void)addButtonWithTitle:(NSString *)title type:(CXAlertViewButtonType)type handler:(CXAlertButtonHandler)handler 256 | { 257 | UIFont *font=[self fontForButtonType:type]; 258 | [self addButtonWithTitle:title type:type handler:handler font:font]; 259 | } 260 | 261 | - (void)setDefaultButtonImage:(UIImage *)defaultButtonImage forState:(UIControlState)state 262 | { 263 | [self setButtonImage:defaultButtonImage forState:state andButtonType:CXAlertViewButtonTypeDefault]; 264 | } 265 | 266 | - (void)setCancelButtonImage:(UIImage *)cancelButtonImage forState:(UIControlState)state 267 | { 268 | [self setButtonImage:cancelButtonImage forState:state andButtonType:CXAlertViewButtonTypeCancel]; 269 | } 270 | 271 | - (void)setCustomButtonImage:(UIImage *)customButtonImage forState:(UIControlState)state 272 | { 273 | [self setButtonImage:customButtonImage forState:state andButtonType:CXAlertViewButtonTypeCustom]; 274 | } 275 | // AlertView action 276 | - (void)show 277 | { 278 | self.oldKeyWindow = [[UIApplication sharedApplication] keyWindow]; 279 | 280 | if (![[CXAlertView sharedQueue] containsObject:self]) { 281 | [[CXAlertView sharedQueue] addObject:self]; 282 | } 283 | 284 | if ([CXAlertView isAnimating]) { 285 | return; // wait for next turn 286 | } 287 | 288 | if (self.isVisible) { 289 | return; 290 | } 291 | 292 | if ([CXAlertView currentAlertView].isVisible) { 293 | CXAlertView *alert = [CXAlertView currentAlertView]; 294 | [alert dismissWithCleanup:NO]; 295 | return; 296 | } 297 | 298 | if (self.willShowHandler) { 299 | self.willShowHandler(self); 300 | } 301 | 302 | self.visible = YES; 303 | 304 | [CXAlertView setAnimating:YES]; 305 | [CXAlertView setCurrentAlertView:self]; 306 | 307 | // transition background 308 | [CXAlertView showBackground]; 309 | 310 | CXAlertViewController *viewController = [[CXAlertViewController alloc] initWithNibName:nil bundle:nil]; 311 | viewController.alertView = self; 312 | 313 | if ([self.oldKeyWindow.rootViewController respondsToSelector:@selector(prefersStatusBarHidden)]) { 314 | viewController.rootViewControllerPrefersStatusBarHidden = self.oldKeyWindow.rootViewController.prefersStatusBarHidden; 315 | __cx_statsu_prefersStatusBarHidden = self.oldKeyWindow.rootViewController.prefersStatusBarHidden; 316 | } 317 | 318 | if (!self.alertWindow) { 319 | UIWindow *window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 320 | window.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 321 | window.opaque = NO; 322 | window.windowLevel = UIWindowLevelAlert; 323 | window.rootViewController = viewController; 324 | self.alertWindow = window; 325 | } 326 | [self.alertWindow makeKeyAndVisible]; 327 | [self validateLayout]; 328 | 329 | [self transitionInCompletion:^{ 330 | if (self.didShowHandler) { 331 | self.didShowHandler(self); 332 | } 333 | 334 | [CXAlertView setAnimating:NO]; 335 | 336 | NSInteger index = [[CXAlertView sharedQueue] indexOfObject:self]; 337 | if (index < [CXAlertView sharedQueue].count - 1) { 338 | [self dismissWithCleanup:NO]; // dismiss to show next alert view 339 | } 340 | }]; 341 | } 342 | 343 | - (void)dismiss 344 | { 345 | [self dismissWithCleanup:YES]; 346 | } 347 | 348 | - (void)shake 349 | { 350 | CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.translation.x"]; 351 | animation.duration = 0.1; 352 | animation.repeatCount = 3; 353 | animation.autoreverses = YES; 354 | // animation.fromValue = [NSNumber numberWithFloat:0.0]; 355 | animation.toValue = [NSNumber numberWithFloat:10.0]; 356 | [self.layer removeAllAnimations]; 357 | [self.layer addAnimation:animation forKey:@"transform.translation.x"]; 358 | 359 | } 360 | // Operation 361 | - (void)cleanAllPenddingAlert 362 | { 363 | [[CXAlertView sharedQueue] removeAllObjects]; 364 | } 365 | 366 | #pragma mark - CXAlertView PV 367 | + (NSMutableArray *)sharedQueue 368 | { 369 | if (!__cx_pending_alert_queue) { 370 | __cx_pending_alert_queue = [NSMutableArray array]; 371 | } 372 | return __cx_pending_alert_queue; 373 | } 374 | 375 | + (CXAlertView *)currentAlertView 376 | { 377 | return __cx_alert_current_view; 378 | } 379 | 380 | + (void)setCurrentAlertView:(CXAlertView *)alertView 381 | { 382 | __cx_alert_current_view = alertView; 383 | } 384 | 385 | + (BOOL)isAnimating 386 | { 387 | return __cx_alert_animating; 388 | } 389 | 390 | + (void)setAnimating:(BOOL)animating 391 | { 392 | __cx_alert_animating = animating; 393 | } 394 | 395 | + (void)showBackground 396 | { 397 | if (!__cx_alert_background_window) { 398 | 399 | CGSize screenSize = [self currentScreenSize]; 400 | 401 | __cx_alert_background_window = [[CXAlertBackgroundWindow alloc] initWithFrame:CGRectMake(0, 0, screenSize.width, screenSize.height)]; 402 | } 403 | 404 | [__cx_alert_background_window makeKeyAndVisible]; 405 | __cx_alert_background_window.alpha = 0; 406 | [UIView animateWithDuration:0.3 407 | animations:^{ 408 | __cx_alert_background_window.alpha = 1; 409 | }]; 410 | } 411 | 412 | + (CGSize)currentScreenSize 413 | { 414 | CGRect frame; 415 | #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 416 | if ([[UIScreen mainScreen] respondsToSelector:@selector(nativeBounds)]) { 417 | frame = [UIScreen mainScreen].nativeBounds; 418 | } 419 | else { 420 | frame = [UIScreen mainScreen].bounds; 421 | } 422 | #else 423 | frame = [UIScreen mainScreen].bounds; 424 | #endif 425 | 426 | CGFloat screenWidth = frame.size.width; 427 | CGFloat screenHeight = frame.size.height; 428 | 429 | UIInterfaceOrientation interfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation]; 430 | if (UIInterfaceOrientationIsLandscape(interfaceOrientation) && ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)) { 431 | CGFloat tmp = screenWidth; 432 | screenWidth = screenHeight; 433 | screenHeight = tmp; 434 | } 435 | 436 | return CGSizeMake(screenWidth, screenHeight); 437 | } 438 | 439 | 440 | + (void)hideBackgroundAnimated:(BOOL)animated 441 | { 442 | if (!animated) { 443 | [__cx_alert_background_window removeFromSuperview]; 444 | __cx_alert_background_window = nil; 445 | return; 446 | } 447 | [UIView animateWithDuration:0.3 448 | animations:^{ 449 | __cx_alert_background_window.alpha = 0; 450 | } 451 | completion:^(BOOL finished) { 452 | [__cx_alert_background_window removeFromSuperview]; 453 | __cx_alert_background_window = nil; 454 | }]; 455 | } 456 | 457 | - (CGFloat)heightWithText:(NSString *)text font:(UIFont *)font 458 | { 459 | if (text) { 460 | CGSize size = CGSizeZero; 461 | CGSize rSize = CGSizeMake(self.containerWidth - 2*self.vericalPadding - 1, NSUIntegerMax); 462 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_7_0 463 | NSDictionary* attributes = [NSDictionary dictionaryWithObjectsAndKeys: font, NSFontAttributeName, nil]; 464 | CGRect rect = [text boundingRectWithSize:rSize options:NSStringDrawingUsesLineFragmentOrigin attributes:attributes context:nil]; 465 | size = rect.size; 466 | #else 467 | size = [text sizeWithFont:font constrainedToSize:rSize]; 468 | #endif 469 | return size.height; 470 | } 471 | 472 | return 0; 473 | } 474 | 475 | - (CGFloat)preferredHeight 476 | { 477 | CGFloat height = 0; 478 | height += ([self heightForTopScrollView] + self.scrollViewPadding); 479 | height += ([self heightForContentScrollView] + self.scrollViewPadding); 480 | height += ([self heightForBottomScrollView] + self.scrollViewPadding); 481 | return height; 482 | } 483 | 484 | - (CGFloat)heightForTopScrollView 485 | { 486 | return MAX(self.topScrollViewMinHeight, MIN(self.topScrollViewMaxHeight, CGRectGetHeight(_titleLabel.frame))); 487 | } 488 | 489 | - (CGFloat)heightForContentScrollView 490 | { 491 | return MAX(self.contentScrollViewMinHeight, MIN(self.contentScrollViewMaxHeight, CGRectGetHeight(self.contentView.frame))); 492 | } 493 | 494 | - (CGFloat)heightForBottomScrollView 495 | { 496 | if (self.buttons.count > 0) { 497 | return _maxButtonHeight; 498 | } 499 | return self.bottomScrollViewHeight; 500 | } 501 | 502 | - (void)setup 503 | { 504 | [self setupContainerView]; 505 | [self setupScrollViews]; 506 | [self updateTopScrollView]; 507 | [self updateContentScrollView]; 508 | [self updateBottomScrollView]; 509 | } 510 | 511 | - (void)tearDown 512 | { 513 | [self.containerView removeFromSuperview]; 514 | [self.blurView removeFromSuperview]; 515 | 516 | [self.titleLabel removeFromSuperview]; 517 | self.titleLabel = nil; 518 | 519 | [self.alertWindow removeFromSuperview]; 520 | self.alertWindow = nil; 521 | self.layoutDirty = NO; 522 | } 523 | 524 | - (void)validateLayout 525 | { 526 | if (!self.isLayoutDirty) { 527 | return; 528 | } 529 | self.layoutDirty = NO; 530 | 531 | CGFloat height = [self preferredHeight]; 532 | CGFloat left = (self.bounds.size.width - self.containerWidth) * 0.5; 533 | CGFloat top = (self.bounds.size.height - height) * 0.5; 534 | _containerView.transform = CGAffineTransformIdentity; 535 | _blurView.transform = CGAffineTransformIdentity; 536 | if (_updateAnimated) { 537 | _updateAnimated = NO; 538 | [UIView animateWithDuration:0.3 animations:^{ 539 | _containerView.frame = CGRectMake(left, top, self.containerWidth, height); 540 | _blurView.frame = CGRectMake(left, top, self.containerWidth, height); 541 | }]; 542 | } 543 | else { 544 | _containerView.frame = CGRectMake(left, top, self.containerWidth, height); 545 | _blurView.frame = CGRectMake(left, top, self.containerWidth, height); 546 | } 547 | _containerView.layer.shadowPath = [UIBezierPath bezierPathWithRoundedRect:_containerView.bounds cornerRadius:_containerView.layer.cornerRadius].CGPath; 548 | } 549 | 550 | - (void)invalidateLayout 551 | { 552 | self.layoutDirty = YES; 553 | [self setNeedsLayout]; 554 | } 555 | 556 | - (void)resetTransition 557 | { 558 | [_containerView.layer removeAllAnimations]; 559 | } 560 | // Scroll Views 561 | - (void)setupContainerView 562 | { 563 | _containerView = [[UIView alloc] initWithFrame:self.bounds]; 564 | [self addSubview:self.containerView]; 565 | 566 | _containerView.clipsToBounds = YES; 567 | 568 | _containerView.backgroundColor = _viewBackgroundColor ? _viewBackgroundColor : [UIColor whiteColor]; 569 | _containerView.layer.cornerRadius = self.cornerRadius; 570 | _containerView.layer.shadowOffset = CGSizeZero; 571 | _containerView.layer.shadowRadius = self.shadowRadius; 572 | // _containerView.layer.shadowOpacity = 1.; 573 | 574 | [self updateBlurBackground]; 575 | } 576 | 577 | - (void)setupScrollViews 578 | { 579 | if (!_topScrollView) { 580 | _topScrollView = [[UIScrollView alloc] init]; 581 | } 582 | 583 | if (!_contentScrollView) { 584 | _contentScrollView = [[UIScrollView alloc] init]; 585 | _contentScrollView.autoresizesSubviews = NO; 586 | } 587 | 588 | if (!_bottomScrollView) { 589 | _bottomScrollView = [[CXAlertButtonContainerView alloc] init]; 590 | _bottomScrollView.defaultTopLineVisible = _showButtonLine; 591 | _bottomScrollView.showsHorizontalScrollIndicator = NO; 592 | } 593 | } 594 | 595 | - (void)updateTopScrollView 596 | { 597 | if (self.title) { 598 | if (!_titleLabel) { 599 | _titleLabel = [[UILabel alloc] init]; 600 | [_topScrollView addSubview:_titleLabel]; 601 | } 602 | _titleLabel.textAlignment = NSTextAlignmentCenter; 603 | _titleLabel.backgroundColor = [UIColor clearColor]; 604 | _titleLabel.font = self.titleFont; 605 | _titleLabel.textColor = self.titleColor; 606 | _titleLabel.adjustsFontSizeToFitWidth = YES; 607 | _titleLabel.numberOfLines = 0; 608 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_6_0 609 | _titleLabel.minimumScaleFactor = 0.75; 610 | #else 611 | _titleLabel.minimumFontSize = self.titleLabel.font.pointSize * 0.75; 612 | #endif 613 | _titleLabel.frame = CGRectMake( self.vericalPadding, 0, self.containerWidth - self.vericalPadding*2, [self heightWithText:self.title font:_titleLabel.font]); 614 | _titleLabel.text = self.title; 615 | 616 | _topScrollView.frame = CGRectMake( 0 , self.scrollViewPadding, self.containerWidth, [self heightForTopScrollView]); 617 | _topScrollView.contentSize = _titleLabel.bounds.size; 618 | 619 | if (![_containerView.subviews containsObject:_topScrollView]) { 620 | [_containerView addSubview:_topScrollView]; 621 | } 622 | 623 | [_topScrollView setScrollEnabled:([self heightForTopScrollView] < CGRectGetHeight(_titleLabel.frame))]; 624 | 625 | } 626 | else { 627 | [_titleLabel removeFromSuperview]; 628 | _titleLabel = nil; 629 | [_topScrollView setFrame:CGRectZero]; 630 | [_topScrollView removeFromSuperview]; 631 | } 632 | } 633 | 634 | - (void)updateContentScrollView 635 | { 636 | for (UIView *view in _contentScrollView.subviews) { 637 | [view removeFromSuperview]; 638 | } 639 | 640 | if (_contentView) { 641 | 642 | if (CGRectGetWidth(_contentView.frame) < self.containerWidth) { 643 | CGRect frame = _contentView.frame; 644 | frame.origin.x = (self.containerWidth - CGRectGetWidth(_contentView.frame))/2; 645 | _contentView.frame = frame; 646 | } 647 | 648 | [_contentScrollView addSubview:_contentView]; 649 | 650 | CGFloat y = 0; 651 | y += [self heightForTopScrollView] + self.scrollViewPadding; 652 | 653 | y += self.scrollViewPadding; 654 | 655 | _contentScrollView.frame = CGRectMake( 0, y, self.containerWidth, [self heightForContentScrollView]); 656 | _contentScrollView.contentSize = _contentView.bounds.size; 657 | 658 | if (![_containerView.subviews containsObject:_contentScrollView]) { 659 | [_containerView addSubview:_contentScrollView]; 660 | } 661 | 662 | [_contentScrollView setScrollEnabled:([self heightForContentScrollView] < CGRectGetHeight(_contentView.frame))]; 663 | } 664 | else { 665 | [_contentScrollView setFrame:CGRectZero]; 666 | [_contentScrollView removeFromSuperview]; 667 | } 668 | 669 | [self invalidateLayout]; 670 | } 671 | 672 | - (void)updateBottomScrollView 673 | { 674 | _bottomScrollView.defaultTopLineVisible = _showButtonLine; 675 | 676 | CGFloat y = 0; 677 | 678 | y += [self heightForTopScrollView] + self.scrollViewPadding; 679 | 680 | y += [self heightForContentScrollView] + self.scrollViewPadding; 681 | 682 | y += self.scrollViewPadding; 683 | 684 | _bottomScrollView.backgroundColor = [UIColor clearColor]; 685 | _bottomScrollView.frame = CGRectMake( 0, y, self.containerWidth, [self heightForBottomScrollView]); 686 | 687 | if (![_containerView.subviews containsObject:_bottomScrollView]) { 688 | [_containerView addSubview:_bottomScrollView]; 689 | } 690 | 691 | [self invalidateLayout]; 692 | } 693 | 694 | - (void)dismissWithCleanup:(BOOL)cleanup 695 | { 696 | BOOL isVisible = self.isVisible; 697 | 698 | if (isVisible) { 699 | if (self.willDismissHandler) { 700 | self.willDismissHandler(self); 701 | } 702 | } 703 | 704 | void (^dismissComplete)(void) = ^{ 705 | self.visible = NO; 706 | [self tearDown]; 707 | 708 | [CXAlertView setCurrentAlertView:nil]; 709 | 710 | // show next alertView 711 | CXAlertView *nextAlertView; 712 | NSInteger index = [[CXAlertView sharedQueue] indexOfObject:self]; 713 | if (index != NSNotFound && index < [CXAlertView sharedQueue].count - 1) { 714 | nextAlertView = [CXAlertView sharedQueue][index + 1]; 715 | } 716 | 717 | if (cleanup) { 718 | [[CXAlertView sharedQueue] removeObject:self]; 719 | } 720 | 721 | [CXAlertView setAnimating:NO]; 722 | 723 | if (isVisible) { 724 | if (self.didDismissHandler) { 725 | self.didDismissHandler(self); 726 | } 727 | } 728 | 729 | // check if we should show next alert 730 | if (!isVisible) { 731 | return; 732 | } 733 | 734 | if (nextAlertView) { 735 | [nextAlertView show]; 736 | } else { 737 | // show last alert view 738 | if ([CXAlertView sharedQueue].count > 0) { 739 | CXAlertView *alert = [[CXAlertView sharedQueue] lastObject]; 740 | [alert show]; 741 | } 742 | } 743 | }; 744 | 745 | if (isVisible) { 746 | [CXAlertView setAnimating:YES]; 747 | [self transitionOutCompletion:dismissComplete]; 748 | 749 | if ([CXAlertView sharedQueue].count == 1) { 750 | [CXAlertView hideBackgroundAnimated:YES]; 751 | } 752 | 753 | } else { 754 | dismissComplete(); 755 | 756 | if ([CXAlertView sharedQueue].count == 0) { 757 | [CXAlertView hideBackgroundAnimated:YES]; 758 | } 759 | } 760 | 761 | [_oldKeyWindow makeKeyWindow]; 762 | _oldKeyWindow.hidden = NO; 763 | } 764 | // Transition 765 | - (void)transitionInCompletion:(void(^)(void))completion 766 | { 767 | _containerView.alpha = 0; 768 | _containerView.transform = CGAffineTransformMakeScale(1.2, 1.2); 769 | 770 | _blurView.alpha = 0.9; 771 | _blurView.transform = CGAffineTransformMakeScale(1.2, 1.2); 772 | 773 | [UIView animateWithDuration:0.3 774 | animations:^{ 775 | _containerView.alpha = 1.; 776 | _containerView.transform = CGAffineTransformMakeScale(1.0,1.0); 777 | 778 | _blurView.alpha = 1.; 779 | _blurView.transform = CGAffineTransformMakeScale(1.0,1.0); 780 | } 781 | completion:^(BOOL finished) { 782 | [_blurView blur]; 783 | if (completion) { 784 | completion(); 785 | } 786 | }]; 787 | } 788 | 789 | - (void)transitionOutCompletion:(void(^)(void))completion 790 | { 791 | [UIView animateWithDuration:0.25 792 | animations:^{ 793 | _containerView.alpha = 0; 794 | _containerView.transform = CGAffineTransformMakeScale(0.9,0.9); 795 | 796 | _blurView.alpha = 0.9; 797 | _blurView.transform = CGAffineTransformMakeScale(0.9,0.9); 798 | } 799 | completion:^(BOOL finished) { 800 | if (completion) { 801 | completion(); 802 | } 803 | }]; 804 | } 805 | 806 | // Buttons 807 | -(UIFont*)fontForButtonType:(CXAlertViewButtonType)type 808 | { 809 | UIFont *font = nil; 810 | if(type==CXAlertViewButtonTypeCancel) 811 | { 812 | font = self.cancelButtonFont; 813 | } 814 | else if(type==CXAlertViewButtonTypeCustom) 815 | { 816 | font = self.customButtonFont; 817 | } 818 | else 819 | { 820 | font = self.buttonFont; 821 | } 822 | 823 | return font; 824 | } 825 | 826 | - (CGRect)frameWithButtonTitile:(NSString *)title type:(CXAlertViewButtonType)type 827 | { 828 | self.buttonHeight = kDefaultButtonHeight; 829 | CGRect frame; 830 | frame.size = CGSizeMake(self.containerWidth/2, self.buttonHeight); 831 | 832 | if (_buttons.count == 1) { 833 | frame.origin = CGPointMake(0., 0.); 834 | frame.size.width = self.containerWidth; 835 | } 836 | else if (_buttons.count == 2) { 837 | frame.origin = CGPointMake(self.containerWidth/2, 0.); 838 | } 839 | else { 840 | CXAlertButtonItem *lastButton = _buttons[_buttons.count - 2]; 841 | frame.origin = CGPointMake(CGRectGetMaxX(lastButton.frame), 0); 842 | } 843 | 844 | UIFont *font = [self fontForButtonType:type]; 845 | 846 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_7_0 847 | CGRect rect = [title boundingRectWithSize:CGSizeMake(frame.size.width, CGFLOAT_MAX) options:(NSStringDrawingUsesFontLeading | NSStringDrawingUsesLineFragmentOrigin) attributes:@{NSFontAttributeName:font} context:nil]; 848 | CGFloat newHeight = rect.size.height; 849 | #else 850 | CGFloat newHeight = [title sizeWithFont:font constrainedToSize:frame.size lineBreakMode:BT_LBM].height; 851 | #endif 852 | 853 | frame.size.height = MAX(newHeight, self.buttonHeight); 854 | 855 | _maxButtonHeight = MAX(_maxButtonHeight, frame.size.height); 856 | 857 | return frame; 858 | } 859 | 860 | - (void)addButtonWithTitle:(NSString *)title type:(CXAlertViewButtonType)type handler:(CXAlertButtonHandler)handler font:(UIFont *)font 861 | { 862 | CXAlertButtonItem *lastButton = [_buttons lastObject]; 863 | lastButton.defaultRightLineVisible = _showButtonLine; 864 | 865 | CXAlertButtonItem *button = [self buttonItemWithType:type font:font]; 866 | button.title = title; 867 | button.action = handler; 868 | button.type = type; 869 | button.defaultRightLineVisible = NO; 870 | [button setTitle:title forState:UIControlStateNormal]; 871 | 872 | button.titleLabel.textAlignment=TA_CENTER; 873 | [button.titleLabel setNumberOfLines:0]; 874 | button.titleLabel.lineBreakMode=BT_LBM; 875 | // [button setTitleEdgeInsets:UIEdgeInsetsMake(10.0, 10.0, 10.0, 10.0)]; 876 | 877 | CGFloat contentWidthOffset = 0.; 878 | [_buttons addObject:button]; 879 | 880 | if ([_buttons count] == 1) 881 | { 882 | button.defaultRightLineVisible = NO; 883 | button.frame = [self frameWithButtonTitile:title type:type]; 884 | } 885 | else 886 | { 887 | // correct first button 888 | CXAlertButtonItem *firstButton = [_buttons objectAtIndex:0]; 889 | firstButton.defaultRightLineVisible = _showButtonLine; 890 | CGFloat lastFirstButtonWidth = CGRectGetWidth(firstButton.frame); 891 | CGRect newFrame = CGRectMake( 0, 0, self.containerWidth/2, CGRectGetHeight(firstButton.frame)); 892 | newFrame.origin.x = 0; 893 | contentWidthOffset = lastFirstButtonWidth - CGRectGetWidth(newFrame); 894 | 895 | if (self.isVisible) { 896 | CGRect buttonFrame = [self frameWithButtonTitile:title type:type]; 897 | button.alpha = 0.; 898 | button.frame = CGRectMake( 0, 0, CGRectGetWidth(buttonFrame), CGRectGetHeight(buttonFrame)); 899 | [UIView animateWithDuration:0.3 animations:^{ 900 | firstButton.frame = newFrame; 901 | button.alpha = 1.; 902 | button.frame = buttonFrame; 903 | }]; 904 | } 905 | else { 906 | firstButton.frame = newFrame; 907 | button.alpha = 1.; 908 | button.frame = [self frameWithButtonTitile:title type:type]; 909 | } 910 | } 911 | 912 | [_bottomScrollView addSubview:button]; 913 | 914 | _bottomScrollView.contentSize = CGSizeMake(CGRectGetMaxX(button.frame), _maxButtonHeight); 915 | } 916 | 917 | - (CXAlertButtonItem *)buttonItemWithType:(CXAlertViewButtonType)type font:(UIFont *)font 918 | { 919 | CXAlertButtonItem *button = [CXAlertButtonItem buttonWithType:UIButtonTypeCustom]; 920 | // button.autoresizingMask = UIViewAutoresizingFlexibleWidth; 921 | button.titleLabel.font = font; 922 | UIImage *normalImage = nil; 923 | UIImage *highlightedImage = nil; 924 | switch (type) { 925 | case CXAlertViewButtonTypeCancel: 926 | [button setTitleColor:self.cancelButtonColor forState:UIControlStateNormal]; 927 | [button setTitleColor:[self.cancelButtonColor colorWithAlphaComponent:0.8] forState:UIControlStateHighlighted]; 928 | break; 929 | case CXAlertViewButtonTypeCustom: 930 | [button setTitleColor:self.customButtonColor forState:UIControlStateNormal]; 931 | [button setTitleColor:[self.customButtonColor colorWithAlphaComponent:0.8] forState:UIControlStateHighlighted]; 932 | break; 933 | case CXAlertViewButtonTypeDefault: 934 | default: 935 | [button setTitleColor:self.buttonColor forState:UIControlStateNormal]; 936 | [button setTitleColor:[self.buttonColor colorWithAlphaComponent:0.8] forState:UIControlStateHighlighted]; 937 | break; 938 | } 939 | CGFloat hInset = floorf(normalImage.size.width / 2); 940 | CGFloat vInset = floorf(normalImage.size.height / 2); 941 | UIEdgeInsets insets = UIEdgeInsetsMake(vInset, hInset, vInset, hInset); 942 | normalImage = [normalImage resizableImageWithCapInsets:insets]; 943 | highlightedImage = [highlightedImage resizableImageWithCapInsets:insets]; 944 | [button setBackgroundImage:normalImage forState:UIControlStateNormal]; 945 | [button setBackgroundImage:highlightedImage forState:UIControlStateHighlighted]; 946 | [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside]; 947 | 948 | return button; 949 | } 950 | 951 | - (void)buttonAction:(CXAlertButtonItem *)buttonItem 952 | { 953 | if (buttonItem.action) { 954 | buttonItem.action(self,buttonItem); 955 | } 956 | } 957 | 958 | - (void)setButtonImage:(UIImage *)image forState:(UIControlState)state andButtonType:(CXAlertViewButtonType)type 959 | { 960 | for (CXAlertButtonItem *button in _buttons) 961 | { 962 | if(button.type == type) 963 | { 964 | [button setBackgroundImage:image forState:state]; 965 | } 966 | } 967 | } 968 | 969 | - (void)updateAllButtonsFont 970 | { 971 | for (CXAlertButtonItem *button in _buttons) { 972 | switch (button.type) { 973 | case CXAlertViewButtonTypeCancel: 974 | button.titleLabel.font = self.cancelButtonFont; 975 | break; 976 | case CXAlertViewButtonTypeCustom: 977 | button.titleLabel.font = self.customButtonFont; 978 | break; 979 | case CXAlertViewButtonTypeDefault: 980 | default: 981 | button.titleLabel.font = self.buttonFont; 982 | break; 983 | } 984 | } 985 | } 986 | 987 | - (void)updateBlurBackground 988 | { 989 | UIColor *containerBKGColor = _viewBackgroundColor ? _viewBackgroundColor : [UIColor whiteColor]; 990 | self.blurView.backgroundView.backgroundColor = containerBKGColor; 991 | self.containerView.backgroundColor = [containerBKGColor colorWithAlphaComponent:_showBlurBackground ? 0. : 1.];; 992 | 993 | if (_showBlurBackground) { 994 | if (self.blurView == nil) { 995 | self.blurView = [[CXBlurView alloc] initWithFrame:self.containerView.frame]; 996 | self.blurView.clipsToBounds = YES; 997 | self.blurView.layer.cornerRadius = self.cornerRadius; 998 | } 999 | [self insertSubview:self.blurView belowSubview:self.containerView]; 1000 | } else { 1001 | [self.blurView removeFromSuperview]; 1002 | } 1003 | } 1004 | #pragma mark - Setter 1005 | - (void)setTitle:(NSString *)title 1006 | { 1007 | if (_title != title) { 1008 | _title = title; 1009 | 1010 | _updateAnimated = YES; 1011 | [self updateTopScrollView]; 1012 | [self updateContentScrollView]; 1013 | [self updateBottomScrollView]; 1014 | [self invalidateLayout]; 1015 | } 1016 | } 1017 | 1018 | - (void)setContentView:(UIView *)contentView 1019 | { 1020 | if (_contentView != contentView) { 1021 | _contentView = contentView; 1022 | 1023 | _updateAnimated = YES; 1024 | [self updateContentScrollView]; 1025 | [self updateBottomScrollView]; 1026 | [self invalidateLayout]; 1027 | } 1028 | } 1029 | 1030 | - (void)setButtonHeight:(CGFloat)buttonHeight 1031 | { 1032 | if (_buttonHeight == buttonHeight) { 1033 | return; 1034 | } 1035 | _buttonHeight = buttonHeight; 1036 | 1037 | if (_bottomScrollViewHeight < _buttonHeight) { 1038 | _bottomScrollViewHeight = _buttonHeight; 1039 | [self updateBottomScrollView]; 1040 | } 1041 | } 1042 | 1043 | - (void)setBottomScrollViewHeight:(CGFloat)bottomScrollViewHeight 1044 | { 1045 | if (_bottomScrollViewHeight == bottomScrollViewHeight) { 1046 | return; 1047 | } 1048 | _bottomScrollViewHeight = bottomScrollViewHeight; 1049 | [self updateBottomScrollView]; 1050 | } 1051 | #pragma mark - UIAppearance setters 1052 | 1053 | - (void)setViewBackgroundColor:(UIColor *)viewBackgroundColor 1054 | { 1055 | if (_viewBackgroundColor == viewBackgroundColor) { 1056 | return; 1057 | } 1058 | _viewBackgroundColor = viewBackgroundColor; 1059 | self.containerView.backgroundColor = viewBackgroundColor; 1060 | [self updateBlurBackground]; 1061 | } 1062 | 1063 | - (void)setTitleFont:(UIFont *)titleFont 1064 | { 1065 | if (_titleFont == titleFont) { 1066 | return; 1067 | } 1068 | _titleFont = titleFont; 1069 | self.titleLabel.font = titleFont; 1070 | [self invalidateLayout]; 1071 | } 1072 | 1073 | - (void)setTitleColor:(UIColor *)titleColor 1074 | { 1075 | if (_titleColor == titleColor) { 1076 | return; 1077 | } 1078 | _titleColor = titleColor; 1079 | self.titleLabel.textColor = titleColor; 1080 | } 1081 | 1082 | - (void)setButtonFont:(UIFont *)buttonFont 1083 | { 1084 | if (_buttonFont == buttonFont) { 1085 | return; 1086 | } 1087 | _buttonFont = buttonFont; 1088 | [self updateAllButtonsFont]; 1089 | } 1090 | 1091 | - (void)setCornerRadius:(CGFloat)cornerRadius 1092 | { 1093 | if (_cornerRadius == cornerRadius) { 1094 | return; 1095 | } 1096 | _cornerRadius = cornerRadius; 1097 | self.containerView.layer.cornerRadius = cornerRadius; 1098 | self.blurView.layer.cornerRadius = cornerRadius; 1099 | } 1100 | 1101 | - (void)setShadowRadius:(CGFloat)shadowRadius 1102 | { 1103 | if (_shadowRadius == shadowRadius) { 1104 | return; 1105 | } 1106 | _shadowRadius = shadowRadius; 1107 | self.containerView.layer.shadowRadius = shadowRadius; 1108 | } 1109 | 1110 | - (void)setButtonColor:(UIColor *)buttonColor 1111 | { 1112 | if (_buttonColor == buttonColor) { 1113 | return; 1114 | } 1115 | _buttonColor = buttonColor; 1116 | [self setColor:buttonColor toButtonsOfType:CXAlertViewButtonTypeDefault]; 1117 | } 1118 | 1119 | - (void)setCancelButtonColor:(UIColor *)buttonColor 1120 | { 1121 | if (_cancelButtonColor == buttonColor) { 1122 | return; 1123 | } 1124 | _cancelButtonColor = buttonColor; 1125 | [self setColor:buttonColor toButtonsOfType:CXAlertViewButtonTypeCancel]; 1126 | } 1127 | 1128 | - (void)setCancelButtonFont:(UIFont *)cancelButtonFont 1129 | { 1130 | if (_cancelButtonFont == cancelButtonFont) { 1131 | return; 1132 | } 1133 | _cancelButtonFont = cancelButtonFont; 1134 | [self updateAllButtonsFont]; 1135 | } 1136 | 1137 | - (void)setCustomButtonColor:(UIColor *)buttonColor 1138 | { 1139 | if (_customButtonColor == buttonColor) { 1140 | return; 1141 | } 1142 | _customButtonColor = buttonColor; 1143 | [self setColor:buttonColor toButtonsOfType:CXAlertViewButtonTypeCustom]; 1144 | } 1145 | 1146 | - (void)setCustomButtonFont:(UIFont *)customButtonFont 1147 | { 1148 | if (_customButtonFont == customButtonFont) { 1149 | return; 1150 | } 1151 | _customButtonFont = customButtonFont; 1152 | [self updateAllButtonsFont]; 1153 | } 1154 | 1155 | -(void)setColor:(UIColor *)color toButtonsOfType:(CXAlertViewButtonType)type { 1156 | for (CXAlertButtonItem *button in _buttons) { 1157 | if (button.type == type) { 1158 | [button setTitleColor:color forState:UIControlStateNormal]; 1159 | [button setTitleColor:[color colorWithAlphaComponent:0.8] forState:UIControlStateHighlighted]; 1160 | } 1161 | } 1162 | } 1163 | 1164 | - (void)setShowBlurBackground:(BOOL)showBlurBackground 1165 | { 1166 | if (_showBlurBackground == showBlurBackground) { 1167 | return; 1168 | } 1169 | _showBlurBackground = showBlurBackground; 1170 | [self updateBlurBackground]; 1171 | } 1172 | 1173 | - (void)setShowButtonLine:(BOOL)showButtonLine 1174 | { 1175 | if (_showButtonLine == showButtonLine) { 1176 | return; 1177 | } 1178 | _showButtonLine = showButtonLine; 1179 | [self updateBottomScrollView]; 1180 | } 1181 | @end 1182 | -------------------------------------------------------------------------------- /CXAlertView/CXAlertViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // CXAlertViewController.h 3 | // CXAlertViewDemo 4 | // 5 | // Created by ChrisXu on 13/9/12. 6 | // Copyright (c) 2013年 ChrisXu. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "CXAlertView.h" 11 | 12 | @interface CXAlertViewController : UIViewController 13 | 14 | @property (nonatomic, strong) CXAlertView *alertView; 15 | 16 | @property (nonatomic, assign) BOOL rootViewControllerPrefersStatusBarHidden; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /CXAlertView/CXAlertViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // CXAlertViewController.m 3 | // CXAlertViewDemo 4 | // 5 | // Created by ChrisXu on 13/9/12. 6 | // Copyright (c) 2013年 ChrisXu. All rights reserved. 7 | // 8 | 9 | #import "CXAlertViewController.h" 10 | 11 | @interface CXAlertView () 12 | 13 | - (void)setup; 14 | - (void)resetTransition; 15 | - (void)invalidateLayout; 16 | 17 | @end 18 | 19 | @interface CXAlertViewController () 20 | 21 | @end 22 | 23 | @implementation CXAlertViewController 24 | 25 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 26 | { 27 | self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 28 | if (self) { 29 | // Custom initialization 30 | } 31 | return self; 32 | } 33 | 34 | #pragma mark - View life cycle 35 | 36 | - (void)loadView 37 | { 38 | self.view = self.alertView; 39 | } 40 | 41 | - (void)viewDidLoad 42 | { 43 | [super viewDidLoad]; 44 | [self.alertView setup]; 45 | 46 | [UIApplication sharedApplication].statusBarHidden = _rootViewControllerPrefersStatusBarHidden; 47 | } 48 | 49 | - (void)viewWillAppear:(BOOL)animated 50 | { 51 | [super viewWillAppear:animated]; 52 | 53 | [UIApplication sharedApplication].statusBarHidden = _rootViewControllerPrefersStatusBarHidden; 54 | } 55 | 56 | - (void)viewDidDisappear:(BOOL)animated 57 | { 58 | [super viewDidDisappear:animated]; 59 | 60 | [UIApplication sharedApplication].statusBarHidden = _rootViewControllerPrefersStatusBarHidden; 61 | } 62 | 63 | - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration 64 | { 65 | [self.alertView resetTransition]; 66 | [self.alertView invalidateLayout]; 67 | } 68 | 69 | - (UIInterfaceOrientationMask)supportedInterfaceOrientations 70 | { 71 | return UIInterfaceOrientationMaskAll; 72 | } 73 | 74 | - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation 75 | { 76 | return YES; 77 | } 78 | 79 | - (BOOL)shouldAutorotate 80 | { 81 | return YES; 82 | } 83 | - (BOOL)prefersStatusBarHidden 84 | { 85 | return _rootViewControllerPrefersStatusBarHidden; 86 | } 87 | @end 88 | -------------------------------------------------------------------------------- /CXAlertView/CXBlurView.h: -------------------------------------------------------------------------------- 1 | // 2 | // CXBlurView.h 3 | // CXAlertViewDemo 4 | // 5 | // Created by Chris Xu on 2014/2/7. 6 | // Copyright (c) 2014年 ChrisXu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface CXBlurView : UIView 12 | 13 | @property (nonatomic, strong) UIView *backgroundView; 14 | 15 | - (void)blur; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /CXAlertView/CXBlurView.m: -------------------------------------------------------------------------------- 1 | // 2 | // CXBlurView.m 3 | // CXAlertViewDemo 4 | // 5 | // Created by Chris Xu on 2014/2/7. 6 | // Copyright (c) 2014年 ChrisXu. All rights reserved. 7 | // 8 | 9 | #import "CXBlurView.h" 10 | 11 | @interface CXBlurView () 12 | 13 | @property (nonatomic, strong) UIToolbar *toolbar; 14 | 15 | - (void)setup; 16 | 17 | @end 18 | 19 | @implementation CXBlurView 20 | 21 | - (id)initWithFrame:(CGRect)frame 22 | { 23 | self = [super initWithFrame:frame]; 24 | if (self) { 25 | [self setup]; 26 | } 27 | return self; 28 | } 29 | 30 | - (id)init 31 | { 32 | self = [super init]; 33 | if (self) { 34 | [self setup]; 35 | } 36 | return self; 37 | } 38 | 39 | - (void)layoutSubviews 40 | { 41 | [super layoutSubviews]; 42 | } 43 | 44 | - (void)setFrame:(CGRect)frame 45 | { 46 | [super setFrame:frame]; 47 | 48 | _toolbar.frame = self.bounds; 49 | _backgroundView.frame = self.bounds; 50 | } 51 | 52 | #pragma mark - PB 53 | - (void)blur 54 | { 55 | [UIView animateWithDuration:0.3 animations:^{ 56 | _backgroundView.alpha = 0.7; 57 | }]; 58 | } 59 | 60 | #pragma - PV 61 | - (void)setup 62 | { 63 | if (!_toolbar) { 64 | _toolbar = [[UIToolbar alloc] initWithFrame:self.bounds]; 65 | _toolbar.translucent = YES; 66 | _toolbar.barStyle = UIBarStyleBlack; 67 | [self.layer insertSublayer:_toolbar.layer atIndex:0]; 68 | 69 | _backgroundView = [[UIView alloc] initWithFrame:self.bounds]; 70 | _backgroundView.alpha = 1.; 71 | _backgroundView.backgroundColor = [UIColor whiteColor]; 72 | [self.layer insertSublayer:_backgroundView.layer above:_toolbar.layer]; 73 | } 74 | } 75 | 76 | @end 77 | -------------------------------------------------------------------------------- /CXAlertViewDemo/CXAlertViewDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 835710E417E18FDF004C8155 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 835710E317E18FDF004C8155 /* UIKit.framework */; }; 11 | 835710E617E18FDF004C8155 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 835710E517E18FDF004C8155 /* Foundation.framework */; }; 12 | 835710E817E18FDF004C8155 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 835710E717E18FDF004C8155 /* CoreGraphics.framework */; }; 13 | 835710EE17E18FDF004C8155 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 835710EC17E18FDF004C8155 /* InfoPlist.strings */; }; 14 | 835710F017E18FDF004C8155 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 835710EF17E18FDF004C8155 /* main.m */; }; 15 | 835710F417E18FDF004C8155 /* CXAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 835710F317E18FDF004C8155 /* CXAppDelegate.m */; }; 16 | 835710F617E18FDF004C8155 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 835710F517E18FDF004C8155 /* Default.png */; }; 17 | 835710F817E18FDF004C8155 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 835710F717E18FDF004C8155 /* Default@2x.png */; }; 18 | 835710FA17E18FDF004C8155 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 835710F917E18FDF004C8155 /* Default-568h@2x.png */; }; 19 | 835710FD17E18FDF004C8155 /* CXViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 835710FC17E18FDF004C8155 /* CXViewController.m */; }; 20 | 8357110017E18FDF004C8155 /* CXViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 835710FE17E18FDF004C8155 /* CXViewController.xib */; }; 21 | 8357110917E1917D004C8155 /* CXAlertView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8357110817E1917D004C8155 /* CXAlertView.m */; }; 22 | 8357116C17E1A745004C8155 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8357116B17E1A745004C8155 /* QuartzCore.framework */; }; 23 | 83AB028817F2A551005E51C4 /* CXAlertButtonContainerView.m in Sources */ = {isa = PBXBuildFile; fileRef = 83AB028717F2A551005E51C4 /* CXAlertButtonContainerView.m */; }; 24 | 83AB028A17F2C26E005E51C4 /* bkg.png in Resources */ = {isa = PBXBuildFile; fileRef = 83AB028917F2C26E005E51C4 /* bkg.png */; }; 25 | 83AB028C17F2C439005E51C4 /* taipei101.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 83AB028B17F2C439005E51C4 /* taipei101.jpg */; }; 26 | 83B3A84417E9B18D001BCBC6 /* CXAlertViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 83B3A84317E9B18D001BCBC6 /* CXAlertViewController.m */; }; 27 | 83B3A84A17E9B1A7001BCBC6 /* CXAlertButtonItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 83B3A84917E9B1A7001BCBC6 /* CXAlertButtonItem.m */; }; 28 | 83E10DD517F53A5500BC5D18 /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 83E10DD417F53A5500BC5D18 /* Accelerate.framework */; }; 29 | 83E10DD717F549F400BC5D18 /* bkg2.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 83E10DD617F549F400BC5D18 /* bkg2.jpg */; }; 30 | A852506B18A4DC2500D85CCF /* CXBlurView.m in Sources */ = {isa = PBXBuildFile; fileRef = A852506A18A4DC2500D85CCF /* CXBlurView.m */; }; 31 | /* End PBXBuildFile section */ 32 | 33 | /* Begin PBXFileReference section */ 34 | 835710E017E18FDF004C8155 /* CXAlertViewDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CXAlertViewDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 35 | 835710E317E18FDF004C8155 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 36 | 835710E517E18FDF004C8155 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 37 | 835710E717E18FDF004C8155 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 38 | 835710EB17E18FDF004C8155 /* CXAlertViewDemo-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "CXAlertViewDemo-Info.plist"; sourceTree = ""; }; 39 | 835710ED17E18FDF004C8155 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 40 | 835710EF17E18FDF004C8155 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 41 | 835710F117E18FDF004C8155 /* CXAlertViewDemo-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "CXAlertViewDemo-Prefix.pch"; sourceTree = ""; }; 42 | 835710F217E18FDF004C8155 /* CXAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CXAppDelegate.h; sourceTree = ""; }; 43 | 835710F317E18FDF004C8155 /* CXAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CXAppDelegate.m; sourceTree = ""; }; 44 | 835710F517E18FDF004C8155 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = ""; }; 45 | 835710F717E18FDF004C8155 /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = ""; }; 46 | 835710F917E18FDF004C8155 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; 47 | 835710FB17E18FDF004C8155 /* CXViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CXViewController.h; sourceTree = ""; }; 48 | 835710FC17E18FDF004C8155 /* CXViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CXViewController.m; sourceTree = ""; }; 49 | 835710FF17E18FDF004C8155 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/CXViewController.xib; sourceTree = ""; }; 50 | 8357110717E1917D004C8155 /* CXAlertView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CXAlertView.h; sourceTree = ""; }; 51 | 8357110817E1917D004C8155 /* CXAlertView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CXAlertView.m; sourceTree = ""; }; 52 | 8357116B17E1A745004C8155 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; 53 | 83AB028617F2A551005E51C4 /* CXAlertButtonContainerView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CXAlertButtonContainerView.h; sourceTree = ""; }; 54 | 83AB028717F2A551005E51C4 /* CXAlertButtonContainerView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CXAlertButtonContainerView.m; sourceTree = ""; }; 55 | 83AB028917F2C26E005E51C4 /* bkg.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = bkg.png; sourceTree = ""; }; 56 | 83AB028B17F2C439005E51C4 /* taipei101.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = taipei101.jpg; sourceTree = ""; }; 57 | 83B3A84217E9B18D001BCBC6 /* CXAlertViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CXAlertViewController.h; sourceTree = ""; }; 58 | 83B3A84317E9B18D001BCBC6 /* CXAlertViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CXAlertViewController.m; sourceTree = ""; }; 59 | 83B3A84817E9B1A7001BCBC6 /* CXAlertButtonItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CXAlertButtonItem.h; sourceTree = ""; }; 60 | 83B3A84917E9B1A7001BCBC6 /* CXAlertButtonItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CXAlertButtonItem.m; sourceTree = ""; }; 61 | 83E10DD417F53A5500BC5D18 /* Accelerate.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Accelerate.framework; path = System/Library/Frameworks/Accelerate.framework; sourceTree = SDKROOT; }; 62 | 83E10DD617F549F400BC5D18 /* bkg2.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = bkg2.jpg; sourceTree = ""; }; 63 | A852506918A4DC2500D85CCF /* CXBlurView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CXBlurView.h; sourceTree = ""; }; 64 | A852506A18A4DC2500D85CCF /* CXBlurView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CXBlurView.m; sourceTree = ""; }; 65 | /* End PBXFileReference section */ 66 | 67 | /* Begin PBXFrameworksBuildPhase section */ 68 | 835710DD17E18FDF004C8155 /* Frameworks */ = { 69 | isa = PBXFrameworksBuildPhase; 70 | buildActionMask = 2147483647; 71 | files = ( 72 | 83E10DD517F53A5500BC5D18 /* Accelerate.framework in Frameworks */, 73 | 8357116C17E1A745004C8155 /* QuartzCore.framework in Frameworks */, 74 | 835710E417E18FDF004C8155 /* UIKit.framework in Frameworks */, 75 | 835710E617E18FDF004C8155 /* Foundation.framework in Frameworks */, 76 | 835710E817E18FDF004C8155 /* CoreGraphics.framework in Frameworks */, 77 | ); 78 | runOnlyForDeploymentPostprocessing = 0; 79 | }; 80 | /* End PBXFrameworksBuildPhase section */ 81 | 82 | /* Begin PBXGroup section */ 83 | 835710D717E18FDF004C8155 = { 84 | isa = PBXGroup; 85 | children = ( 86 | 835710E917E18FDF004C8155 /* CXAlertViewDemo */, 87 | 835710E217E18FDF004C8155 /* Frameworks */, 88 | 835710E117E18FDF004C8155 /* Products */, 89 | ); 90 | sourceTree = ""; 91 | }; 92 | 835710E117E18FDF004C8155 /* Products */ = { 93 | isa = PBXGroup; 94 | children = ( 95 | 835710E017E18FDF004C8155 /* CXAlertViewDemo.app */, 96 | ); 97 | name = Products; 98 | sourceTree = ""; 99 | }; 100 | 835710E217E18FDF004C8155 /* Frameworks */ = { 101 | isa = PBXGroup; 102 | children = ( 103 | 83E10DD417F53A5500BC5D18 /* Accelerate.framework */, 104 | 8357116B17E1A745004C8155 /* QuartzCore.framework */, 105 | 835710E317E18FDF004C8155 /* UIKit.framework */, 106 | 835710E517E18FDF004C8155 /* Foundation.framework */, 107 | 835710E717E18FDF004C8155 /* CoreGraphics.framework */, 108 | ); 109 | name = Frameworks; 110 | sourceTree = ""; 111 | }; 112 | 835710E917E18FDF004C8155 /* CXAlertViewDemo */ = { 113 | isa = PBXGroup; 114 | children = ( 115 | 8357110617E18FFD004C8155 /* CXAlertView */, 116 | 835710F217E18FDF004C8155 /* CXAppDelegate.h */, 117 | 835710F317E18FDF004C8155 /* CXAppDelegate.m */, 118 | 835710FB17E18FDF004C8155 /* CXViewController.h */, 119 | 835710FC17E18FDF004C8155 /* CXViewController.m */, 120 | 835710FE17E18FDF004C8155 /* CXViewController.xib */, 121 | 835710EA17E18FDF004C8155 /* Supporting Files */, 122 | ); 123 | path = CXAlertViewDemo; 124 | sourceTree = ""; 125 | }; 126 | 835710EA17E18FDF004C8155 /* Supporting Files */ = { 127 | isa = PBXGroup; 128 | children = ( 129 | 83AB028917F2C26E005E51C4 /* bkg.png */, 130 | 83E10DD617F549F400BC5D18 /* bkg2.jpg */, 131 | 83AB028B17F2C439005E51C4 /* taipei101.jpg */, 132 | 835710EB17E18FDF004C8155 /* CXAlertViewDemo-Info.plist */, 133 | 835710EC17E18FDF004C8155 /* InfoPlist.strings */, 134 | 835710EF17E18FDF004C8155 /* main.m */, 135 | 835710F117E18FDF004C8155 /* CXAlertViewDemo-Prefix.pch */, 136 | 835710F517E18FDF004C8155 /* Default.png */, 137 | 835710F717E18FDF004C8155 /* Default@2x.png */, 138 | 835710F917E18FDF004C8155 /* Default-568h@2x.png */, 139 | ); 140 | name = "Supporting Files"; 141 | sourceTree = ""; 142 | }; 143 | 8357110617E18FFD004C8155 /* CXAlertView */ = { 144 | isa = PBXGroup; 145 | children = ( 146 | 83B3A84817E9B1A7001BCBC6 /* CXAlertButtonItem.h */, 147 | 83B3A84917E9B1A7001BCBC6 /* CXAlertButtonItem.m */, 148 | 83AB028617F2A551005E51C4 /* CXAlertButtonContainerView.h */, 149 | 83AB028717F2A551005E51C4 /* CXAlertButtonContainerView.m */, 150 | 83B3A84217E9B18D001BCBC6 /* CXAlertViewController.h */, 151 | 83B3A84317E9B18D001BCBC6 /* CXAlertViewController.m */, 152 | 8357110717E1917D004C8155 /* CXAlertView.h */, 153 | 8357110817E1917D004C8155 /* CXAlertView.m */, 154 | A852506918A4DC2500D85CCF /* CXBlurView.h */, 155 | A852506A18A4DC2500D85CCF /* CXBlurView.m */, 156 | ); 157 | name = CXAlertView; 158 | path = ../../CXAlertView; 159 | sourceTree = ""; 160 | }; 161 | /* End PBXGroup section */ 162 | 163 | /* Begin PBXNativeTarget section */ 164 | 835710DF17E18FDF004C8155 /* CXAlertViewDemo */ = { 165 | isa = PBXNativeTarget; 166 | buildConfigurationList = 8357110317E18FDF004C8155 /* Build configuration list for PBXNativeTarget "CXAlertViewDemo" */; 167 | buildPhases = ( 168 | 835710DC17E18FDF004C8155 /* Sources */, 169 | 835710DD17E18FDF004C8155 /* Frameworks */, 170 | 835710DE17E18FDF004C8155 /* Resources */, 171 | ); 172 | buildRules = ( 173 | ); 174 | dependencies = ( 175 | ); 176 | name = CXAlertViewDemo; 177 | productName = CXAlertViewDemo; 178 | productReference = 835710E017E18FDF004C8155 /* CXAlertViewDemo.app */; 179 | productType = "com.apple.product-type.application"; 180 | }; 181 | /* End PBXNativeTarget section */ 182 | 183 | /* Begin PBXProject section */ 184 | 835710D817E18FDF004C8155 /* Project object */ = { 185 | isa = PBXProject; 186 | attributes = { 187 | CLASSPREFIX = CX; 188 | LastUpgradeCheck = 0460; 189 | ORGANIZATIONNAME = ChrisXu; 190 | }; 191 | buildConfigurationList = 835710DB17E18FDF004C8155 /* Build configuration list for PBXProject "CXAlertViewDemo" */; 192 | compatibilityVersion = "Xcode 3.2"; 193 | developmentRegion = English; 194 | hasScannedForEncodings = 0; 195 | knownRegions = ( 196 | en, 197 | ); 198 | mainGroup = 835710D717E18FDF004C8155; 199 | productRefGroup = 835710E117E18FDF004C8155 /* Products */; 200 | projectDirPath = ""; 201 | projectRoot = ""; 202 | targets = ( 203 | 835710DF17E18FDF004C8155 /* CXAlertViewDemo */, 204 | ); 205 | }; 206 | /* End PBXProject section */ 207 | 208 | /* Begin PBXResourcesBuildPhase section */ 209 | 835710DE17E18FDF004C8155 /* Resources */ = { 210 | isa = PBXResourcesBuildPhase; 211 | buildActionMask = 2147483647; 212 | files = ( 213 | 835710EE17E18FDF004C8155 /* InfoPlist.strings in Resources */, 214 | 835710F617E18FDF004C8155 /* Default.png in Resources */, 215 | 835710F817E18FDF004C8155 /* Default@2x.png in Resources */, 216 | 835710FA17E18FDF004C8155 /* Default-568h@2x.png in Resources */, 217 | 8357110017E18FDF004C8155 /* CXViewController.xib in Resources */, 218 | 83AB028A17F2C26E005E51C4 /* bkg.png in Resources */, 219 | 83AB028C17F2C439005E51C4 /* taipei101.jpg in Resources */, 220 | 83E10DD717F549F400BC5D18 /* bkg2.jpg in Resources */, 221 | ); 222 | runOnlyForDeploymentPostprocessing = 0; 223 | }; 224 | /* End PBXResourcesBuildPhase section */ 225 | 226 | /* Begin PBXSourcesBuildPhase section */ 227 | 835710DC17E18FDF004C8155 /* Sources */ = { 228 | isa = PBXSourcesBuildPhase; 229 | buildActionMask = 2147483647; 230 | files = ( 231 | A852506B18A4DC2500D85CCF /* CXBlurView.m in Sources */, 232 | 835710F017E18FDF004C8155 /* main.m in Sources */, 233 | 835710F417E18FDF004C8155 /* CXAppDelegate.m in Sources */, 234 | 835710FD17E18FDF004C8155 /* CXViewController.m in Sources */, 235 | 8357110917E1917D004C8155 /* CXAlertView.m in Sources */, 236 | 83B3A84417E9B18D001BCBC6 /* CXAlertViewController.m in Sources */, 237 | 83B3A84A17E9B1A7001BCBC6 /* CXAlertButtonItem.m in Sources */, 238 | 83AB028817F2A551005E51C4 /* CXAlertButtonContainerView.m in Sources */, 239 | ); 240 | runOnlyForDeploymentPostprocessing = 0; 241 | }; 242 | /* End PBXSourcesBuildPhase section */ 243 | 244 | /* Begin PBXVariantGroup section */ 245 | 835710EC17E18FDF004C8155 /* InfoPlist.strings */ = { 246 | isa = PBXVariantGroup; 247 | children = ( 248 | 835710ED17E18FDF004C8155 /* en */, 249 | ); 250 | name = InfoPlist.strings; 251 | sourceTree = ""; 252 | }; 253 | 835710FE17E18FDF004C8155 /* CXViewController.xib */ = { 254 | isa = PBXVariantGroup; 255 | children = ( 256 | 835710FF17E18FDF004C8155 /* en */, 257 | ); 258 | name = CXViewController.xib; 259 | sourceTree = ""; 260 | }; 261 | /* End PBXVariantGroup section */ 262 | 263 | /* Begin XCBuildConfiguration section */ 264 | 8357110117E18FDF004C8155 /* Debug */ = { 265 | isa = XCBuildConfiguration; 266 | buildSettings = { 267 | ALWAYS_SEARCH_USER_PATHS = NO; 268 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 269 | CLANG_CXX_LIBRARY = "libc++"; 270 | CLANG_ENABLE_OBJC_ARC = YES; 271 | CLANG_WARN_CONSTANT_CONVERSION = YES; 272 | CLANG_WARN_EMPTY_BODY = YES; 273 | CLANG_WARN_ENUM_CONVERSION = YES; 274 | CLANG_WARN_INT_CONVERSION = YES; 275 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 276 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 277 | COPY_PHASE_STRIP = NO; 278 | GCC_C_LANGUAGE_STANDARD = gnu99; 279 | GCC_DYNAMIC_NO_PIC = NO; 280 | GCC_OPTIMIZATION_LEVEL = 0; 281 | GCC_PREPROCESSOR_DEFINITIONS = ( 282 | "DEBUG=1", 283 | "$(inherited)", 284 | ); 285 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 286 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 287 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 288 | GCC_WARN_UNUSED_VARIABLE = YES; 289 | IPHONEOS_DEPLOYMENT_TARGET = 6.1; 290 | ONLY_ACTIVE_ARCH = YES; 291 | SDKROOT = iphoneos; 292 | }; 293 | name = Debug; 294 | }; 295 | 8357110217E18FDF004C8155 /* Release */ = { 296 | isa = XCBuildConfiguration; 297 | buildSettings = { 298 | ALWAYS_SEARCH_USER_PATHS = NO; 299 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 300 | CLANG_CXX_LIBRARY = "libc++"; 301 | CLANG_ENABLE_OBJC_ARC = YES; 302 | CLANG_WARN_CONSTANT_CONVERSION = YES; 303 | CLANG_WARN_EMPTY_BODY = YES; 304 | CLANG_WARN_ENUM_CONVERSION = YES; 305 | CLANG_WARN_INT_CONVERSION = YES; 306 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 307 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 308 | COPY_PHASE_STRIP = YES; 309 | GCC_C_LANGUAGE_STANDARD = gnu99; 310 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 311 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 312 | GCC_WARN_UNUSED_VARIABLE = YES; 313 | IPHONEOS_DEPLOYMENT_TARGET = 6.1; 314 | OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; 315 | SDKROOT = iphoneos; 316 | VALIDATE_PRODUCT = YES; 317 | }; 318 | name = Release; 319 | }; 320 | 8357110417E18FDF004C8155 /* Debug */ = { 321 | isa = XCBuildConfiguration; 322 | buildSettings = { 323 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 324 | GCC_PREFIX_HEADER = "CXAlertViewDemo/CXAlertViewDemo-Prefix.pch"; 325 | INFOPLIST_FILE = "CXAlertViewDemo/CXAlertViewDemo-Info.plist"; 326 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 327 | PRODUCT_NAME = "$(TARGET_NAME)"; 328 | WRAPPER_EXTENSION = app; 329 | }; 330 | name = Debug; 331 | }; 332 | 8357110517E18FDF004C8155 /* Release */ = { 333 | isa = XCBuildConfiguration; 334 | buildSettings = { 335 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 336 | GCC_PREFIX_HEADER = "CXAlertViewDemo/CXAlertViewDemo-Prefix.pch"; 337 | INFOPLIST_FILE = "CXAlertViewDemo/CXAlertViewDemo-Info.plist"; 338 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 339 | PRODUCT_NAME = "$(TARGET_NAME)"; 340 | WRAPPER_EXTENSION = app; 341 | }; 342 | name = Release; 343 | }; 344 | /* End XCBuildConfiguration section */ 345 | 346 | /* Begin XCConfigurationList section */ 347 | 835710DB17E18FDF004C8155 /* Build configuration list for PBXProject "CXAlertViewDemo" */ = { 348 | isa = XCConfigurationList; 349 | buildConfigurations = ( 350 | 8357110117E18FDF004C8155 /* Debug */, 351 | 8357110217E18FDF004C8155 /* Release */, 352 | ); 353 | defaultConfigurationIsVisible = 0; 354 | defaultConfigurationName = Release; 355 | }; 356 | 8357110317E18FDF004C8155 /* Build configuration list for PBXNativeTarget "CXAlertViewDemo" */ = { 357 | isa = XCConfigurationList; 358 | buildConfigurations = ( 359 | 8357110417E18FDF004C8155 /* Debug */, 360 | 8357110517E18FDF004C8155 /* Release */, 361 | ); 362 | defaultConfigurationIsVisible = 0; 363 | defaultConfigurationName = Release; 364 | }; 365 | /* End XCConfigurationList section */ 366 | }; 367 | rootObject = 835710D817E18FDF004C8155 /* Project object */; 368 | } 369 | -------------------------------------------------------------------------------- /CXAlertViewDemo/CXAlertViewDemo/CXAlertViewDemo-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | ChrisXtudio.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0.1 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0.1 25 | LSRequiresIPhoneOS 26 | 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /CXAlertViewDemo/CXAlertViewDemo/CXAlertViewDemo-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'CXAlertViewDemo' target in the 'CXAlertViewDemo' project 3 | // 4 | 5 | #import 6 | 7 | #ifndef __IPHONE_4_0 8 | #warning "This project uses features only available in iOS SDK 4.0 and later." 9 | #endif 10 | 11 | #ifdef __OBJC__ 12 | #import 13 | #import 14 | #endif 15 | -------------------------------------------------------------------------------- /CXAlertViewDemo/CXAlertViewDemo/CXAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // CXAppDelegate.h 3 | // CXAlertViewDemo 4 | // 5 | // Created by ChrisXu on 13/9/12. 6 | // Copyright (c) 2013年 ChrisXu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class CXViewController; 12 | 13 | @interface CXAppDelegate : UIResponder 14 | 15 | @property (strong, nonatomic) UIWindow *window; 16 | 17 | @property (strong, nonatomic) CXViewController *viewController; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /CXAlertViewDemo/CXAlertViewDemo/CXAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // CXAppDelegate.m 3 | // CXAlertViewDemo 4 | // 5 | // Created by ChrisXu on 13/9/12. 6 | // Copyright (c) 2013年 ChrisXu. All rights reserved. 7 | // 8 | 9 | #import "CXAppDelegate.h" 10 | 11 | #import "CXViewController.h" 12 | 13 | @implementation CXAppDelegate 14 | 15 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 16 | { 17 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 18 | // Override point for customization after application launch. 19 | self.viewController = [[CXViewController alloc] initWithNibName:@"CXViewController" bundle:nil]; 20 | self.window.rootViewController = self.viewController; 21 | [self.window makeKeyAndVisible]; 22 | return YES; 23 | } 24 | 25 | - (void)applicationWillResignActive:(UIApplication *)application 26 | { 27 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 28 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 29 | } 30 | 31 | - (void)applicationDidEnterBackground:(UIApplication *)application 32 | { 33 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 34 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 35 | } 36 | 37 | - (void)applicationWillEnterForeground:(UIApplication *)application 38 | { 39 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 40 | } 41 | 42 | - (void)applicationDidBecomeActive:(UIApplication *)application 43 | { 44 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 45 | } 46 | 47 | - (void)applicationWillTerminate:(UIApplication *)application 48 | { 49 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 50 | } 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /CXAlertViewDemo/CXAlertViewDemo/CXViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // CXViewController.h 3 | // CXAlertViewDemo 4 | // 5 | // Created by ChrisXu on 13/9/12. 6 | // Copyright (c) 2013年 ChrisXu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface CXViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /CXAlertViewDemo/CXAlertViewDemo/CXViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // CXViewController.m 3 | // CXAlertViewDemo 4 | // 5 | // Created by ChrisXu on 13/9/12. 6 | // Copyright (c) 2013年 ChrisXu. All rights reserved. 7 | // 8 | 9 | #import "CXViewController.h" 10 | #import "CXAlertView.h" 11 | 12 | 13 | #define defaultMessageTitle @"Chris Xu" 14 | #define multiLinedMessageContent @"This is an alert view developed by Chris Xu and enhanced by other contributors which allows you to serve following purposes \n\n - show ios7 styled alerts in ios 5 and 6 \n\n - multilined alert texts and button titles \n\n - fully customozable alertview with changable colors,radiuses,fonts..etc \n\n - much more to come" 15 | #define multiLineMessageCancelText @"I dont understand clearly" 16 | #define multiLineMessageAcceptedText @"I understood and accepting it" 17 | 18 | 19 | @interface CXViewController () 20 | 21 | @property (nonatomic, strong) IBOutlet UIView *myInfoView; 22 | 23 | - (IBAction)showSquenceAlertView:(id)sender; 24 | 25 | - (IBAction)showBlurAlert:(id)sender; 26 | 27 | - (IBAction)showCXAlert:(id)sender; 28 | 29 | - (IBAction)showMultiLinedCXAlert:(id)sender; 30 | 31 | - (IBAction)showSystemAlert:(id)sender; 32 | 33 | - (IBAction)showMultiLinedSystemAlert:(id)sender; 34 | 35 | - (IBAction)infoButtonAction:(UIButton *)button; 36 | 37 | @end 38 | 39 | @implementation CXViewController 40 | 41 | - (void)viewDidLoad 42 | { 43 | [super viewDidLoad]; 44 | 45 | // [[CXAlertView appearance] setTitleFont:[UIFont boldSystemFontOfSize:18.]]; 46 | // [[CXAlertView appearance] setTitleColor:[UIColor blackColor]]; 47 | // [[CXAlertView appearance] setCornerRadius:12]; 48 | // [[CXAlertView appearance] setShadowRadius:20]; 49 | // [[CXAlertView appearance] setButtonColor:[UIColor colorWithRed:0.039 green:0.380 blue:0.992 alpha:1.000]]; 50 | // [[CXAlertView appearance] setCancelButtonColor:[UIColor colorWithRed:0.047 green:0.337 blue:1.000 alpha:1.000]]; 51 | // [[CXAlertView appearance] setCustomButtonColor:[UIColor colorWithRed:0.039 green:0.380 blue:0.992 alpha:1.000]]; 52 | } 53 | 54 | - (void)didReceiveMemoryWarning 55 | { 56 | [super didReceiveMemoryWarning]; 57 | // Dispose of any resources that can be recreated. 58 | } 59 | 60 | - (void)viewDidAppear:(BOOL)animated 61 | { 62 | [super viewDidAppear:animated]; 63 | 64 | // Create alertView with the old fashioned way. 65 | CXAlertView *alertView = [[CXAlertView alloc] initWithTitle:@"Steven Jobs" message:@"\"Steven Paul Jobs, the co-founder, two-time CEO, and chairman of Apple Inc., died October 5, 2011, after a long battle with cancer. He was 56. He was is survived by his wife and four children.The achievements in Jobs' career included helping to popularize the personal computer, leading the development of groundbreaking technology products including the Macintosh, iPod, and iPhone, and driving Pixar Animation Studios to prominence. Jobs’ charisma, drive for success and control, and vision contributed to revolutionary changes in the way technology integrates into and affects the daily life of most people in the world.\" - Wikipedia" cancelButtonTitle:nil]; 66 | // Add additional button as you like with block to handle UIControlEventTouchUpInside event. 67 | [alertView addButtonWithTitle:@"Dismiss" 68 | type:CXAlertViewButtonTypeCancel 69 | handler:^(CXAlertView *alertView, CXAlertButtonItem *button) { 70 | // Dismiss alertview 71 | [alertView dismiss]; 72 | }]; 73 | 74 | // This is a demo for changing content at realtime. 75 | [alertView addButtonWithTitle:@"Taipei 101" 76 | type:CXAlertViewButtonTypeDefault 77 | handler:^(CXAlertView *alertView, CXAlertButtonItem *button) { 78 | alertView.title = @"Taipei 101"; 79 | UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"taipei101.jpg"]]; 80 | imageView.backgroundColor = [UIColor clearColor]; 81 | alertView.contentView = imageView; 82 | }]; 83 | 84 | // This is a demo for multiple line of title. 85 | [alertView addButtonWithTitle:@"Multititle" 86 | type:CXAlertViewButtonTypeCustom 87 | handler:^(CXAlertView *alertView, CXAlertButtonItem *button) { 88 | alertView.contentView = nil; 89 | alertView.title = @"This \n is \n a \n multiline \n title demo without content."; 90 | }]; 91 | 92 | [alertView addButtonWithTitle:@"Another" 93 | type:CXAlertViewButtonTypeDefault 94 | handler:^(CXAlertView *alertView, CXAlertButtonItem *button) { 95 | alertView.title = @"Red custom view"; 96 | UIView *view = [[UIView alloc] initWithFrame:CGRectMake( 0, 0, 200, 200)]; 97 | view.backgroundColor = [UIColor redColor]; 98 | alertView.contentView = view; 99 | }]; 100 | 101 | [alertView addButtonWithTitle:@"Shake" 102 | type:CXAlertViewButtonTypeDefault 103 | handler:^(CXAlertView *alertView, CXAlertButtonItem *button) { 104 | 105 | [alertView shake]; 106 | 107 | }]; 108 | 109 | // Remember to call this, or alertview will never be seen. 110 | [alertView show]; 111 | } 112 | 113 | - (BOOL)prefersStatusBarHidden 114 | { 115 | return YES; 116 | } 117 | 118 | - (IBAction)showSquenceAlertView:(id)sender 119 | { 120 | // This is a demo for poping up two alertview. 121 | 122 | // The old fashioned way to show alertview. 123 | CXAlertView *alertViewMe = [[CXAlertView alloc] initWithTitle:defaultMessageTitle contentView:self.myInfoView cancelButtonTitle:@"Sure"]; 124 | alertViewMe.showButtonLine = NO; 125 | 126 | [alertViewMe show]; 127 | 128 | 129 | CXAlertView *alertView = [[CXAlertView alloc] initWithTitle:@"MIT License" message:@"Copyright (c) 2013 Chris Xu, Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php) \n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE." cancelButtonTitle:nil]; 130 | 131 | alertView.willShowHandler = ^(CXAlertView *alertView) { 132 | NSLog(@"%@, willShowHandler", alertView); 133 | }; 134 | alertView.didShowHandler = ^(CXAlertView *alertView) { 135 | NSLog(@"%@, didShowHandler", alertView); 136 | }; 137 | alertView.willDismissHandler = ^(CXAlertView *alertView) { 138 | NSLog(@"%@, willDismissHandler", alertView); 139 | }; 140 | alertView.didDismissHandler = ^(CXAlertView *alertView) { 141 | NSLog(@"%@, didDismissHandler", alertView); 142 | }; 143 | 144 | 145 | [alertView addButtonWithTitle:@"Confirm" 146 | type:CXAlertViewButtonTypeDefault 147 | handler:^(CXAlertView *alertView, CXAlertButtonItem *button) { 148 | button.enabled = NO; 149 | [button setTitleColor:[UIColor grayColor] forState:UIControlStateDisabled]; 150 | [alertView addButtonWithTitle:@"OK" 151 | type:CXAlertViewButtonTypeCancel 152 | handler:^(CXAlertView *alertView, CXAlertButtonItem *button) { 153 | [alertView dismiss]; 154 | }]; 155 | }]; 156 | 157 | [alertView show]; 158 | } 159 | 160 | - (IBAction)showBlurAlert:(id)sender 161 | { 162 | CXAlertView *alertView = [[CXAlertView alloc] initWithTitle:@"Blur Background Trigger \n Test" message:nil cancelButtonTitle:@"Dismiss"]; 163 | 164 | [alertView addButtonWithTitle:@"Disable" 165 | type:CXAlertViewButtonTypeCustom 166 | handler:^(CXAlertView *alertView, CXAlertButtonItem *button) { 167 | alertView.showBlurBackground = NO; 168 | }]; 169 | 170 | [alertView addButtonWithTitle:@"Enable" 171 | type:CXAlertViewButtonTypeCustom 172 | handler:^(CXAlertView *alertView, CXAlertButtonItem *button) { 173 | alertView.showBlurBackground = YES; 174 | }]; 175 | 176 | [alertView show]; 177 | } 178 | 179 | - (IBAction)showCXAlert:(id)sender 180 | { 181 | CXAlertView *alertViewMe = [[CXAlertView alloc] initWithTitle:defaultMessageTitle message:@"Something about me...." cancelButtonTitle:@"OK"]; 182 | 183 | [alertViewMe show]; 184 | } 185 | 186 | -(IBAction)showMultiLinedCXAlert:(id)sender 187 | { 188 | CXAlertView *alertViewMe = [[CXAlertView alloc] initWithTitle:defaultMessageTitle message:multiLinedMessageContent cancelButtonTitle:nil]; 189 | 190 | // This is a demo for multiple line of title. 191 | [alertViewMe addButtonWithTitle:multiLineMessageAcceptedText 192 | type:CXAlertViewButtonTypeDefault 193 | handler:^(CXAlertView *alertView, CXAlertButtonItem *button) { 194 | [alertView dismiss]; 195 | }]; 196 | 197 | [alertViewMe addButtonWithTitle:multiLineMessageCancelText 198 | type:CXAlertViewButtonTypeCancel 199 | handler:^(CXAlertView *alertView, CXAlertButtonItem *button) { 200 | [alertView dismiss]; 201 | }]; 202 | 203 | [alertViewMe show]; 204 | } 205 | 206 | - (IBAction)showSystemAlert:(id)sender 207 | { 208 | UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:defaultMessageTitle message:@"Something about me...." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil]; 209 | 210 | [alertView show]; 211 | } 212 | 213 | -(IBAction)showMultiLinedSystemAlert:(id)sender 214 | { 215 | UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:defaultMessageTitle message:multiLinedMessageContent delegate:nil cancelButtonTitle:nil otherButtonTitles: nil]; 216 | 217 | [alertView addButtonWithTitle:multiLineMessageAcceptedText]; 218 | alertView.cancelButtonIndex=[alertView addButtonWithTitle:multiLineMessageCancelText]; 219 | 220 | [alertView show]; 221 | } 222 | 223 | - (IBAction)infoButtonAction:(UIButton *)button 224 | { 225 | NSString *urlString = nil; 226 | switch (button.tag) { 227 | case 0: 228 | urlString = @"https://github.com/ChrisXu1221"; 229 | break; 230 | case 1: 231 | urlString = @"http://www.linkedin.com/profile/view?id=143284727"; 232 | break; 233 | case 2: 234 | urlString = @"https://twitter.com/taterctl"; 235 | break; 236 | default: 237 | break; 238 | } 239 | 240 | [[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]]; 241 | } 242 | @end 243 | -------------------------------------------------------------------------------- /CXAlertViewDemo/CXAlertViewDemo/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChrisXu/CXAlertView/eba8353b06e0ce63677f34bbfbdd336e59b5bb85/CXAlertViewDemo/CXAlertViewDemo/Default-568h@2x.png -------------------------------------------------------------------------------- /CXAlertViewDemo/CXAlertViewDemo/Default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChrisXu/CXAlertView/eba8353b06e0ce63677f34bbfbdd336e59b5bb85/CXAlertViewDemo/CXAlertViewDemo/Default.png -------------------------------------------------------------------------------- /CXAlertViewDemo/CXAlertViewDemo/Default@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChrisXu/CXAlertView/eba8353b06e0ce63677f34bbfbdd336e59b5bb85/CXAlertViewDemo/CXAlertViewDemo/Default@2x.png -------------------------------------------------------------------------------- /CXAlertViewDemo/CXAlertViewDemo/bkg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChrisXu/CXAlertView/eba8353b06e0ce63677f34bbfbdd336e59b5bb85/CXAlertViewDemo/CXAlertViewDemo/bkg.png -------------------------------------------------------------------------------- /CXAlertViewDemo/CXAlertViewDemo/bkg2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChrisXu/CXAlertView/eba8353b06e0ce63677f34bbfbdd336e59b5bb85/CXAlertViewDemo/CXAlertViewDemo/bkg2.jpg -------------------------------------------------------------------------------- /CXAlertViewDemo/CXAlertViewDemo/en.lproj/CXViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 39 | 55 | 71 | 87 | 103 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 142 | 158 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | -------------------------------------------------------------------------------- /CXAlertViewDemo/CXAlertViewDemo/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /CXAlertViewDemo/CXAlertViewDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // CXAlertViewDemo 4 | // 5 | // Created by ChrisXu on 13/9/12. 6 | // Copyright (c) 2013年 ChrisXu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "CXAppDelegate.h" 12 | 13 | int main(int argc, char *argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([CXAppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /CXAlertViewDemo/CXAlertViewDemo/taipei101.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChrisXu/CXAlertView/eba8353b06e0ce63677f34bbfbdd336e59b5bb85/CXAlertViewDemo/CXAlertViewDemo/taipei101.jpg -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Chris Xu 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | CXAlertView 2 | =========== 3 | 4 | #### Sorry guys, I was busy in survival a startup last year. I will make an update ASAP. You can mail me if you have any thoughts about improvement. 5 | 6 | Version 1.1.0 7 | 8 | * Replace `LiveFrost` by native blur function 9 | * Simulate appearance in iOS7.1 10 | * Bug fix 11 | 12 | Version 1.0.1 13 | 14 | >You cannot customize the appearance of alert views.' - [iOS 7 Design Resources ](https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/UIKitUICatalog/UIAlertView.html#//apple_ref/doc/uid/TP40012857-UIAlertView-SW1) 15 | 16 | If you ever try to mess up with the UIAlertView, it is easy. Go to add at least five buttons on it. Therefore We change the layout with buttons. 17 | 18 | This is a custom alert view developed by Chris Xu and enhanced by other contributors which allows you to following things 19 | * Show ios7 styled alerts in ios 5 and 6. 20 | 21 | ![ScreenShot 2](screenshot2.png) 22 | * Unlike iOS 6 and below , on IOS 7 is non-customisable i.e., you can't modify to customise it. This alert allows you to Add view as you like in iOS7. 23 | 24 | ![ScreenShot 1](screenshot1.png) 25 | 26 | * Multilined alert texts and button titles. 27 | 28 | ![Multilined Button Titles](screenshot-multilined-buttons.png) 29 | * Fully customizable alertview with interchangable colors,radiuses,fonts..etc. 30 | 31 | --- 32 | 33 | 34 | ## Installation 35 | 36 | * CocoaPods add `pod 'CXAlertView'` 37 | 38 | * If using as a git submodule, you will also need to add [LiveFrost](https://github.com/radi/LiveFrost.git) 39 | 40 | ## How to use 41 | --- 42 | 43 | ```Objective-C 44 | // Create 45 | - (id)initWithTitle:(NSString *)title message:(NSString *)message cancelButtonTitle:(NSString *)cancelButtonTitle; 46 | - (id)initWithTitle:(NSString *)title contentView:(UIView *)contentView cancelButtonTitle:(NSString *)cancelButtonTitle; 47 | // Buttons 48 | - (void)addButtonWithTitle:(NSString *)title type:(CXAlertViewButtonType)type handler:(CXAlertViewHandler)handler; 49 | - (void)setDefaultButtonImage:(UIImage *)defaultButtonImage forState:(UIControlState)state NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR; 50 | // AlertView action 51 | - (void)show; 52 | - (void)dismiss; 53 | // Operation 54 | - (void)cleanAllPenddingAlert; 55 | ``` 56 | 57 | ##### There are three parts of alertview, Top (Title View), Middle (Content View) and Bottom (Buttons Container). 58 | 59 | * `showButtonLine` show buttons dividing line. 60 | * `showBlurBackground` use blur background. 61 | 62 | ## Next 63 | --- 64 | 65 | * Replace blur function by `UIVisualEffect` in iOS8 66 | * Bug fix. 67 | 68 | 69 | ## Thanks 70 | --- 71 | * [SIAlertView](https://github.com/Sumi-Interactive/SIAlertView) for some tips to build this. 72 | 73 | ## Support 74 | --- 75 | * Xcode 5 76 | * Framework : QuartzCore, Accelerate 77 | * ARC 78 | 79 | ## Contact 80 | --- 81 | #### Chris Xu 82 | 83 | * [@GitHub](https://github.com/ChrisXu1221) 84 | * [@Twitter](https://twitter.com/taterctl) 85 | * [@Mail](mailto:taterctl@gmail.com) 86 | 87 | ## License 88 | --- 89 | Copyright (c) 2013 Chris Xu, Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php) 90 | 91 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 92 | 93 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 94 | 95 | THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 96 | 97 | 98 | [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/ChrisXu1221/cxalertview/trend.png)](https://bitdeli.com/free "Bitdeli Badge") 99 | 100 | -------------------------------------------------------------------------------- /screenshot-multilined-buttons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChrisXu/CXAlertView/eba8353b06e0ce63677f34bbfbdd336e59b5bb85/screenshot-multilined-buttons.png -------------------------------------------------------------------------------- /screenshot1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChrisXu/CXAlertView/eba8353b06e0ce63677f34bbfbdd336e59b5bb85/screenshot1.png -------------------------------------------------------------------------------- /screenshot2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChrisXu/CXAlertView/eba8353b06e0ce63677f34bbfbdd336e59b5bb85/screenshot2.png --------------------------------------------------------------------------------