高仿系统图原生UIAlertController

2020-03-17  本文已影响0人  Gxdy

支持

用法

    'TLAlertLib', '~> 1.0.0'
TLAlertController *alertController = [TLAlertController alertControllerWithTitle:@"故乡的云" message:@"Copyright © 2020 故乡的云. All rights reserved" preferredStyle:TLAlertControllerStyleActionSheet];
                 
[alertController addAction:[TLAlertAction actionWithTitle:@"Action (Enabel = NO)" style:TLAlertActionStyleDefault handler:^(TLAlertAction * _Nonnull action) {
    NSLog(@"%@", action.title);
}]];
        
[alertController addAction:[TLAlertAction actionWithTitle:@"Action2 (Default)" style:TLAlertActionStyleDefault handler:^(TLAlertAction * _Nonnull action) {
    NSLog(@"%@", action.title);
}]];
[alertController addAction:[TLAlertAction actionWithTitle:@"Action3 (Destructive)" style:TLAlertActionStyleDestructive handler:^(TLAlertAction * _Nonnull action) {
    NSLog(@"%@", action.title);
}]];

/// 用自定义view作为Action
UIView *redView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bg"]];
redView.userInteractionEnabled = YES;
[alertController addAction:[TLAlertAction actionWithCustomView:redView style:TLAlertActionStyleDestructive handler:^(TLAlertAction * _Nonnull action) {
    NSLog(@"CustomView");
}]];

[alertController addAction:[TLAlertAction actionWithTitle:@"Cancel" style:TLAlertActionStyleCancel handler:nil]];

[alertController showInViewController:self];

示例图

2.jpg 1.jpg 3.jpg 4.jpg
上一篇下一篇

猜你喜欢

热点阅读