IOS7学习之路九(ios7自定义UIAlertView)

IOS7的UIAlertView 不支持自定义,无法添加subview .

不过可以用第三方库git上的下载链接    https://github.com/wimagguc/ios-custom-alertview  

Custom iOS7 AlertView

使用方法:

1.下载

2下载之后解压后把其中的

  • CustomIOS7AlertView.h
  • CustomIOS7AlertView.m
两个文件粘贴到自己的项目中。


3.添加头文件

在需要使用UIAlertView的地方,添加头文件。

#import "CustomIOS7AlertView.h"

并且添加协议。<CustomIOS7AlertViewDelegate>
4.添加AlertView

 CustomIOS7AlertView *alertView = [[CustomIOS7AlertView alloc] init];
    [alertView setButtonTitles:[NSMutableArray arrayWithObjects:@"取消",@"确定", nil]];//添加按钮
    [alertView setContainerView:youcontroller.view];
    [alertView show];

运行结果截图:



很简单就不做具体介绍了,大家可以下载Demo看看:http://download.csdn.net/detail/superlele123/6986895

点击右上角Item弹出AlertView.





原文地址:https://www.cnblogs.com/lixingle/p/3707701.html