ZFAlertController is a Highly customizable AlertController for iOS
ZFAlertController
is a Highly customizable AlertController for iOS.
Choose ZFAlertController
for your next project, or migrate over your existing projects—you’ll be happy you did!
ZFAlertController
to your projectCocoaPods is the recommended way to add ZFAlertController
to your project.
Specify it in your Podfile:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
target 'TargetName' do
pod 'ZFAlertController', '~> 1.0.9'
end
Then, run the following command:
pod install --repo-update
Alternatively you can directly add the ZFAlertController.h
and ZFAlertController.m
source files to your project.
ZFAlertController.h
and ZFAlertController.m
onto your project (use the “Product Navigator view”). Make sure to select Copy items when asked if you extracted the code archive outside of your project.ZFAlertController
wherever you need it with #import "ZFAlertController.h"
.Equal with UIAlertController
ZFAlertController *alertVC = [ZFAlertController alertWithTitle:@"ZFAlertController" message:@"alertWithTitle:message:style:" style:ZFAlertControllerStyleAlert];
ZFAlertAction *ok = [ZFAlertAction actionWithTitle:@"ok" action:^{
}];
ZFAlertAction *cancel = [ZFAlertAction actionWithTitle:@"cancel" action:^{
}];
[alertVC addAction:ok];
[alertVC addAction:cancel];
[self presentViewController:alertVC animated:YES completion:nil];
ZFAlertController *alertVC = [ZFAlertController alertWithTitle:@"Alert" message:@"alertWithTitle:message:style:" style:ZFAlertControllerStyleAlert];
[alertVC addTextFiledWithText:@"" placeholder:@"Input..." textFieldTextChangedCallback:^(NSString * _Nonnull text, UITextField * _Nonnull textField) {
NSLog(@"text1:%@", text);
}];
ZFAlertAction *ok = [ZFAlertAction actionWithTitle:@"Ok" action:^{
NSLog(@"ok");
[self testFunc];
}];
[alertVC addAction:ok];
[self presentViewController:alertVC animated:YES completion:nil];
ZFAlertController *alertVC = [ZFAlertController alertWithTitle:@"ActionSheet" message:@"alertWithTitle:message:style:" style:ZFAlertControllerStyleActionSheet];
ZFAlertAction *ok = [ZFAlertAction actionWithTitle:@"Ok" action:^{
}];
ZFAlertAction *cancel = [ZFAlertAction actionWithTitle:@"Cancel" action:^{
}];
[alertVC addAction:ok];
[alertVC addAction:cancel];
[self presentViewController:alertVC animated:YES completion:nil];
[alertVC addCustomView:^UIView * _Nonnull{
UIView *customView = [[UIView alloc] init];
[customView setBackgroundColor:[UIColor greenColor]];
return customView;
} config:^(UIView * _Nonnull contentView, UIView * _Nonnull customView) {
[customView setFrame:CGRectMake(contentView.frame.origin.x + 40, contentView.frame.origin.y - 40, contentView.frame.size.width - 40 * 2, 30)];
}];
[alertVC addCustomButton:^UIButton * _Nonnull{
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setImage:[UIImage imageNamed:@"close"] forState:UIControlStateNormal];
return button;
} buttonAction:^(UIViewController * _Nonnull alert) {
[alert dismissViewControllerAnimated:YES completion:nil];
} config:^(UIView * _Nonnull contentView, UIView * _Nonnull customView) {
// or masonry here
[customView setFrame:CGRectMake(CGRectGetMaxX(contentView.frame) - 44, contentView.frame.origin.y - 44 - 10, 44, 44)];
}];
And more see sample
in project.
If there any mistake, tell me.
If you feel comfortable, maybe you can take a star🌟
Thank you for your time.
Copyright (c) 2019 Pokeey
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:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
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.