iOS进阶动画iOS项目开发应用

iOS7兼容自定义带动画的AlertViewController

2016-09-01  本文已影响1347人  夏天然后

意为打造类似原生控件样式的控件, 类似于UIAlertViewController
优点在于:


如何使用, 请看示例代码

        // 初始化
        XTAlertViewController *xt = [[XTAlertViewController alloc] init];
        // Give a picture name
        // Give a picture's height
        // Give a btn's title array
        // Give a title
        // Give a describtion
        // Give a style  two btn | double btn
        // example 1: 不采用Header图片, 可以图片参数为空, 或者高度为0, 
        // 分别左右两个按钮的样式 style:AlterDefault(是一个枚举类型)
        [xt initWithImage:@"summerxx" imageHeight:0 title:@"This is an introduction" btnTitles:@[@"Cancel", @"Determine"] des:@"A simple and easy to use more version using the controls Copyright © 2016年 夏天然后. All rights reserved." style:AlertDefault];
        // 推出新的控制器
        [self presentViewController:xt animated:YES completion:^{

        }];
        // example 2: 多按钮 采用Header图片的样式.
        [xt initWithImage:@"summerxx" imageHeight:200 title:@"This is an introduction" btnTitles:@[@"Cancel", @"Determine", @"summerxx"] des:@"A simple and easy to use more version using the controls Copyright © 2016年 夏天然后. All rights reserved." style:AlertDouble];
        // present VC
        [self presentViewController:xt animated:YES completion:^{

        }];

签订协议, 指定代理人

    // Signed an delegate
    @interface ViewController ()<XTAlertControllerDelegate>
    // 
    xt.delegate = self;

实现协议方法

- (void)xt_alertViewControllerClickIndex:(NSInteger)buttonIndex
{

    switch (buttonIndex) {
        case 0:
            NSLog(@"0");
            NSLog(@"Cancel");
        break;
        case 1:
            NSLog(@"1");
            NSLog(@"Determine");
        break;
        case 2:
            NSLog(@"2");
            NSLog(@"summerxx");
        break;
        default:
        break;
    }
}

这是一个支持Cocoapods的小工具(上传遇到了很多问题, 心好累~)

// 1.1.0.beta.1 能够搜到~
Add `pod 'XTAlertViewController', '~> 1.0.1'` to your Podfile
Run `pod install` or pod update --no-repo-update
import 

程序示例入口 https://github.com/summerxx27/XTAlertViewController

感谢简书提供平台记录学习点滴
如果您觉得有帮助, 请给我点个赞或者关注我, 谢谢~

效果图
---------------------------------------

走心文章, 值得点赞 ---文/夏天然后
微博-点我@夏天是个大人了 || QQ群: 498143780

End 文/夏天然后

可以关注我的订阅号 [夏天然后 ID: xt1005430006]

夏天然后
上一篇 下一篇

猜你喜欢

热点阅读