您的位置:首页 > 移动开发 > IOS开发

【iOS学习】十一、ActionSheet

2016-03-18 14:46 531 查看

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标记多个ActionSheet
actionSheet.tag = 100;


(3)点击响应

-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (actionSheet.tag == 100)
{
if (buttonIndex == 0)
{
NSLog("你点击了是");
}
if (buttonIndex == 1)
{
NSLog("你点击了否");
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: