Latest 0.0.2
Homepage https://github.com/ulongx/mpalertview
License MIT
Platforms ios 9.1
Authors

Version
License
Platform

一个可自定义view和button数量的alertview,参考自一个开源项目,找不到了,等找到再补上

screenshots

示例

暂无

环境

  • XCode 8.0+
  • iOS 9.1+

安装

mpalertview 可以通过 CocoaPods 进行获取。只需要在你的 Podfile 中添加如下代码就能实现引入:

pod "mpalertview"

然后,执行如下命令即可:

$ pod install

代码示例

简单使用

#import <mpalertview/mpalertview.h>
...

mpalertview *aview = [[mpalertview alloc]init];
//定义按钮组,可以多个,最好不要超过3个,否则布局不好看
aview.buttonTitles = @[@{@"title":@"取消",@"titleColor":[UIColor whiteColor],@"bgColor":[UIColor greenColor]}
                      ,@{@"title":@"确定",@"titleColor":[UIColor whiteColor],@"bgColor":[UIColor greenColor]}];
aview.bodyMessage = @"是否删除?";
[aview setOnButtonTouchUpInside:^(mpalertview *alertView, int buttonIndex) {
    if (buttonIndex == 0) {
        NSLog(@"点击了第一个按钮");
    }else{
        NSLog(@"点击了第二个按钮");
    }
    [alertView close];
}];
[aview show];
...

添加自定义view

#import <mpalertview/mpalertview.h>
...

UIView *cusview = [UIView new];
...
mpalertview *aview = [[mpalertview alloc]init];
//定义按钮组,可以多个,最好不要超过3个,否则布局不好看
aview.buttonTitles = @[@{@"title":@"取消",@"titleColor":[UIColor whiteColor],@"bgColor":[UIColor greenColor]}
                     ,@{@"title":@"确定",@"titleColor":[UIColor whiteColor],@"bgColor":[UIColor greenColor]}];
aview.containerView = cusview; //把自定义的view,set进去
[aview setOnButtonTouchUpInside:^(mpalertview *alertView, int buttonIndex) {
    if (buttonIndex == 0) {
        NSLog(@"点击了第一个按钮");
    }else{
        NSLog(@"点击了第二个按钮");
    }
    [alertView close];
}];
[aview show];
...

Latest podspec

{
    "name": "mpalertview",
    "version": "0.0.2",
    "summary": "u4e00u4e2au53efu81eau5b9au4e49viewu548cbuttonu6570u91cfu7684alertview",
    "homepage": "https://github.com/ulongx/mpalertview",
    "license": "MIT",
    "authors": {
        "ulongx": "[email protected]"
    },
    "platforms": {
        "ios": "9.1"
    },
    "source": {
        "git": "https://github.com/ulongx/mpalertview.git",
        "tag": "0.0.2"
    },
    "source_files": "mpalertview/*.{h,m}"
}

Pin It on Pinterest

Share This