@@ -32,26 +32,28 @@ Open the downloaded project in Xcode, then drag and drop folder named **CFAlertV
3232The above shown alert and actionsheet can easily be implemented using the code snippet given below by some small tweaks
3333``` swift
3434// Create Alert
35- var alertController: CFAlertViewController = CFAlertViewController (title : " You've hit the limit" ,
36- message : " Looks like you've hit your daily follow/unfollow limit. Upgrade to our paid plan to be able to remove your limits." , textAlignment : . center ,
37- preferredStyle : . alert ) { (didTapBackground) in
38- print ( " Alert Dismissed " )
39- if (didTapBackground) {
40- // Handle background tap here
41- }
35+ var alertController: CFAlertViewController = CFAlertViewController. alertController (title : " You've hit the limit" ,
36+ message : " Looks like you've hit your daily follow/unfollow limit. Upgrade to our paid plan to be able to remove your limits." ,
37+ textAlignment : . left ,
38+ preferredStyle : . alert ) { (didTapBackground) in
39+ if (didTapBackground) {
40+ // Handle background tap here
41+ }
4242}
43+
4344
44- var defaultAction = CFAlertAction (title : " UPGRADE" ,
45- style : .Default ,
46- alignment : .justified ,
47- backgroundColor : UIColor (red : CGFloat (46.0 / 255.0 ), green : CGFloat (204.0 / 255.0 ), blue : CGFloat (113.0 / 255.0 ), alpha : CGFloat (1 )),
48- textColor : UIColor.white ) { (action) in
49- print (" Button with \( action.title ) title tapped" )
45+ var defaultAction = CFAlertAction. action (title : " UPGRADE" ,
46+ style : .Default ,
47+ alignment : .justified ,
48+ backgroundColor : UIColor (red : CGFloat (46.0 / 255.0 ), green : CGFloat (204.0 / 255.0 ), blue : CGFloat (113.0 / 255.0 ), alpha : CGFloat (1 )),
49+ textColor : UIColor.white ) { (action) in
50+ print (" Button with \( action.title ) title tapped" )
5051}
5152
5253// Add Action Button Into Alert
5354alertController.addAction (defaultAction)
54-
55+
56+ // Present Alert View Controller
5557self .present (alertController, animated : true , completion : nil )
5658```
5759
@@ -60,20 +62,24 @@ self.present(alertController, animated: true, completion: nil)
6062### Alerts
6163
6264``` swift
63- convenience init (title : String ? ,
64- message : String ? ,
65- textAlignment : NSTextAlignment,
66- preferredStyle : CFAlertControllerStyle,
67- headerView : UIView? ,
68- footerView : UIView? ,
69- didDismissAlertHandler dismiss : CFAlertViewControllerDismissBlock? )
65+ public class func alertController (title : String ? ,
66+ titleColor : UIColor? ,
67+ message : String ? ,
68+ messageColor : UIColor? ,
69+ textAlignment : NSTextAlignment,
70+ preferredStyle : CFAlertControllerStyle,
71+ headerView : UIView? ,
72+ footerView : UIView? ,
73+ didDismissAlertHandler dismiss : CFAlertViewControllerDismissBlock? ) -> CFAlertViewController
7074```
7175
72- ##### Title and Message
73- You can set custom title and message of the alert (pass nil if you don’t need them).
76+ ##### Title and Message
77+ You can set a custom title and message text in the alert (pass ` nil ` if you don’t need them).
7478
75- ##### Alignment
79+ ##### Title Color and Message Color
80+ You can set a custom title and message text color in the alert (pass ` nil ` if you want to use Default color values).
7681
82+ ##### Alignment
7783You can customise alignment of the title and message. Set the ` textAlignment ` property with one of the following values :
7884
7985``` swift
@@ -121,12 +127,12 @@ A block (of type CFAlertViewControllerDismissBlock) gets called when the Alert /
121127
122128### Actions
123129``` swift
124- convenience init (title : String ? ,
125- style : CFAlertActionStyle,
126- alignment : CFAlertActionAlignment,
127- backgroundColor : UIColor? ,
128- textColor : UIColor? ,
129- handler : CFAlertActionHandlerBlock? )
130+ public class func action (title : String ? ,
131+ style : CFAlertActionStyle,
132+ alignment : CFAlertActionAlignment,
133+ backgroundColor : UIColor? ,
134+ textColor : UIColor? ,
135+ handler : CFAlertActionHandlerBlock? ) -> CFAlertAction
130136```
131137##### Title
132138You can set the title of action button to be added.
@@ -151,5 +157,8 @@ Configure the alignment of the action button added to the alert view. Set `align
151157##### Callback
152158A block (of type CFAlertActionHandlerBlock) gets invoked when action is tapped.
153159
160+ ### Container View
161+ You can also configure the background color or layer related properties (e.g. cornerRadius, borderColor, borderWidth) in the ` containerView ` property.
162+
154163## License
155164This code is distributed under the terms and conditions of the MIT license.
0 commit comments