【iOS学习】十一、ActionSheet

来源:互联网 发布:淘宝便宜的衣服能买吗 编辑:程序博客网 时间:2024/06/06 17:11

ActionSheet

(1)实现协议
在头文件中遵守UIActionSheetDelegate协议。

@interface ActionSheetTest : UIView<UIActionSheetDelegate>

(2)定义

UIActionSheet *actionSheet = [[UIActionSheet alloc]initWithTitle:nil // 标题delegate:self  // 代理cancelButtonTitle:@"取消"  // 取消,系统自带 destructiveButtonTitle:nil  // 确定,系统自带otherButtonTitles:@"是",@"否", nil]; // 自定义其它选项// actionSheet的样式// UIActionSheetStyleBlackOpaque 不透明的深色样式// UIActionSheetStyleBlackTranslucent 半透明的深色样式// UIActionSheetStyleAutomatic 如果屏幕底部有按钮栏,则采用与按钮栏匹配的样式actionSheet.actionSheetStyle = UIActionSheetStyleDefault;// 利用tag标记多个ActionSheetactionSheet.tag = 100;

(3)点击响应

-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{    if (actionSheet.tag == 100)    {        if (buttonIndex == 0)        {            NSLog("你点击了是");        }        if (buttonIndex == 1)        {            NSLog("你点击了否");        }    }}
1 0
原创粉丝点击