自定义UIAlertViewController选择视图
来源:互联网 发布:宏金赛鸽公棚扫猫数据 编辑:程序博客网 时间:2024/06/05 06:43
我的GitHub:点击打开链接
进入我的git,下载项目
在自己的项目中导入头文件
#import "AlertAction.h"
#import "AlertView.h"
实现一下代码即可:
{
//选择图片显示在第几行
NSInteger _actionImgShowRow;
}
@property (weak,nonatomic)IBOutletUILabel *textLabel;
@end
@implementation ViewController
- (void)viewDidLoad {
[superviewDidLoad];
_actionImgShowRow =0;
}
//图片固定不变
- (IBAction)AlertClick:(id)sender {
AlertView *alertView = [AlertViewpopoverView];
alertView.backgroundColor=[UIColorclearColor];
alertView.showShade =YES;//显示阴影背景
[alertView showWithActions:[selfQQActions]];
}
//显示选择行数
- (IBAction)selectAlertClick:(id)sender {
AlertView *alertView = [AlertViewpopoverView];
alertView.backgroundColor=[UIColorclearColor];
alertView.showShade =YES;//显示阴影背景
[alertView showWithActions:[selfselectActions]];
}
//图片不会被隐藏
- (NSMutableArray<AlertAction *> *)QQActions {
// 发起多人聊天 action
AlertAction *multichatAction = [AlertActionactionWithImage:[UIImageimageNamed:@"right_menu_multichat"]title:@"发起多人聊天"handler:^(AlertAction *action) {
_textLabel.text =@"发起多人聊天";
}];
// 加好友 action
AlertAction *addFriAction = [AlertActionactionWithImage:[UIImageimageNamed:@"right_menu_addFri"]title:@"加好友"handler:^(AlertAction *action) {
_textLabel.text =@"加好友";
}];
// 扫一扫 action
AlertAction *QRAction = [AlertActionactionWithImage:[UIImageimageNamed:@"right_menu_QR"]title:@"扫一扫"handler:^(AlertAction *action) {
_textLabel.text =@"扫一扫";
}];
// 面对面快传 action
AlertAction *facetofaceAction = [AlertActionactionWithImage:[UIImageimageNamed:@"right_menu_facetoface"]title:@"面对面快传"handler:^(AlertAction *action) {
_textLabel.text =@"面对面快传";
}];
// 付款 action
AlertAction *payMoneyAction = [AlertActionactionWithImage:[UIImageimageNamed:@"right_menu_payMoney"]title:@"付款"handler:^(AlertAction *action) {
_textLabel.text =@"付款";
}];
// 取消
AlertAction *cancelAction = [AlertActionactionWithTitle:@"取消"handler:^(AlertAction *action) {
_textLabel.text =@"取消";
}];
NSArray *section1 =@[multichatAction, addFriAction, QRAction, facetofaceAction, payMoneyAction];
NSArray *section2 =@[cancelAction];
NSMutableArray *actionArr=[NSMutableArrayarrayWithObjects:section1, section2,nil];
return actionArr;
}
//图片默认隐藏,选择后对应行数显示
- (NSMutableArray<AlertAction *> *)selectActions {
// 全部支付 action
AlertAction *allPayAction = [AlertActionactionWithImage:[UIImageimageNamed:@"selcetShape"]title:@"全部支付"handler:^(AlertAction *action) {
_textLabel.text =@"全部支付";
_actionImgShowRow =0;
}];
// 快捷支付 action
AlertAction *fastAction = [AlertActionactionWithImage:[UIImageimageNamed:@"selcetShape"]title:@"快捷支付"handler:^(AlertAction *action) {
_textLabel.text =@"快捷支付";
_actionImgShowRow =1;
}];
// 银行划账 action
AlertAction *bankAction = [AlertActionactionWithImage:[UIImageimageNamed:@"selcetShape"]title:@"银行划账"handler:^(AlertAction *action) {
_textLabel.text =@"银行划账";
_actionImgShowRow =2;
}];
// 微信支付 action
AlertAction *weixinAction = [AlertActionactionWithImage:[UIImageimageNamed:@"selcetShape"]title:@"微信支付"handler:^(AlertAction *action) {
_textLabel.text =@"微信支付";
_actionImgShowRow =3;
}];
// 支付宝支付 action
AlertAction *zhifubaoAction = [AlertActionactionWithImage:[UIImageimageNamed:@"selcetShape"]title:@"支付宝支付"handler:^(AlertAction *action) {
_textLabel.text =@"支付宝支付";
_actionImgShowRow =4;
}];
// 取消
AlertAction *cancelAction = [AlertActionactionWithTitle:@"取消"handler:^(AlertAction *action) {
_textLabel.text =@"取消";
}];
NSArray *section1 =@[allPayAction, fastAction, bankAction, weixinAction, zhifubaoAction];
NSArray *section2 =@[cancelAction];
AlertAction *alert=[[AlertActionalloc]init];
alert.selectRow =_actionImgShowRow;
NSMutableArray *actionArr=[NSMutableArrayarrayWithObjects:section1, section2, alert,nil];
return actionArr;
}
我的GitHub:点击打开链接
- 自定义UIAlertViewController选择视图
- 使用UIAlertviewController弹出视图
- UIAlertViewController
- UIAlertViewController
- UIAlertViewController
- UIAlertViewController 基本使用+自定义(字体颜色,大小,对齐方式)
- 用runtime自定义UIAlertViewController的字体大小和颜色
- Swift 自定义视图:简单的数量选择控件
- 选择视图
- 视图选择
- iOS8- UIAlertViewController
- UIAlertViewController详解
- iOS8- UIAlertViewController
- 自定义视图-马赛克视图
- 自定义视图
- 自定义视图
- 自定义视图
- 自定义视图
- 为什么声发射信号要做频谱分析时最好用真宽带型传感器?
- 黄焖鸡饭进军美国!兰州拉面你们还在等什么?---众智云
- shell循环执行脚本
- JVM 垃圾检测、回收算法
- 销退方式
- 自定义UIAlertViewController选择视图
- Resource IDs cannot be used in a switch statement in Android library modules
- 网站内容标签元描述的优化细节
- 【LeetCode】100. Same Tree
- MySQL MGR与Galera性能测试
- jQuery操作复选框
- ARP 伪造模拟
- hibernate的入门学习
- Python学习(4)