| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
#CFAlertViewController CFAlertViewController is a library that helps you display and customise alerts and action sheets on iPad and iPhone. It offers screen rotation as well as an adaptive UI support. CFAlertViewController’s functionality is almost similar to the native UIAlertController.
CFAlertViewController works on devices (iPhone and iPad) with iOS 8.0+. It depends on the following Apple frameworks:
We assume that your Cocoapods is already configured. If you are new to Cocoapods, have a look at the documentation
// Add Action Button CFAlertAction *actionDefault = [CFAlertAction actionWithTitle:@"UPGRADE" style:CFAlertActionStyleDefault alignment:CFAlertActionAlignmentJustified color:[UIColor colorWithRed:46.0/255.0 green:204.0/255.0 blue:113.0/255.0 alpha:1] handler: ^(CFAlertAction *action) { NSLog(@"Button with %@ title tapped",action.title); }];
// Add Action Button Into Alert [alert addAction:actionDefault];
// Present Alert [self presentViewController:alert animated:YES completion:nil];
## Customisations :
### Alerts
```objective-c
+ (nonnull instancetype) alertControllerWithTitle:(nullable NSString *)title
message:(nullable NSString *)message
textAlignment:(NSTextAlignment)textAlignment
preferredStyle:(CFAlertControllerStyle)preferredStyle
headerView:(nullable UIView *)headerView
footerView:(nullable UIView *)footerView
didDismissAlertHandler:(nullable CFAlertViewControllerDismissBlock)dismiss;
You can set custom title and message of the alert (pass nil if you don’t need them).
You can customise alignment of the title and message. Set the textAlignment property with one of the following values :
NSTextAlignmentLeft,
NSTextAlignmentRight,
NSTextAlignmentCenterPresentation style of the alert can be customised as Alert or Action sheet. Just set the preferredStyle property with one of the following values :
CFAlertControllerStyleAlert,
CFAlertControllerStyleActionSheetYou can add header and footer to the alert. Set properties headerView and footerView with custom views (subclass of UIView). You can pass nil to this properties to opt them out.
A block (of type CFAlertViewControllerDismissBlock) gets called when the Alert / Action Sheet is dismissed. You can use it to handle call back.
+ (nullable instancetype) actionWithTitle:(nonnull NSString *)title
style:(CFAlertActionStyle)style
alignment:(CFAlertActionAlignment)alignment
color:(nullable UIColor *)color
handler:(nullable CFAlertActionHandlerBlock)handler;You can set the title of action button to be added.
Configure the style of the action button that is to be added to alert view. Set style property of the above method with one of the following Action style
CFAlertActionStyleDefault,
CFAlertActionStyleCancel,
CFAlertActionStyleDestructiveConfigure the alignment of the action button added to the alert view. Set alignment property of CFAction constructor with one of the following action types
CFAlertActionAlignmentJustified, // Action Button occupies the full width
CFAlertActionAlignmentRight,
CFAlertActionAlignmentLeft,
CFAlertActionAlignmentCenterA block (of type CFAlertActionHandlerBlock) gets invoked when action is tapped.
##License This code is distributed under the terms and conditions of the MIT license.
| Back | FazBrowse Home | New Git URL |