使用如下方法定义UIActionSheet,其中颜色按钮的颜色为红色。
UIActionSheet *ActionSheet = [[UIActionSheet alloc] initWithTitle:@" "
delegate:selfcancelButtonTitle:@"删除"
destructiveButtonTitle:@"颜色"
otherButtonTitles:@"Done",nil];
[ActionSheet setActionSheetStyle:UIActionSheetStyleDefault];
1、修改颜色按钮的颜色为默认的蓝色的方法
UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"" delegate:self
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];
[sheet addButtonWithTitle:@"颜色"];
[sheet addButtonWithTitle:@"删除"];
sheet.cancelButtonIndex = sheet.numberOfButtons-1;
2、修改按钮的颜色为其他颜色的方法
实现代理方法
- (void)willPresentActionSheet:(UIActionSheet *)actionSheet
{
for (UIView *subViwe in actionSheet.subviews) {
if ([subViwe isKindOfClass:[UIButton class]]) {
UIButton *button = (UIButton*)subViwe;
[button setTitleColor:[UIColor blueColor]
forState:UIControlStateNormal];
}
}
}
本文介绍如何使用iOS中的UIActionSheet并自定义按钮颜色。包括将颜色按钮从默认红色更改为蓝色的方法,以及如何通过代理方法更改所有按钮颜色的具体实现。
1892

被折叠的 条评论
为什么被折叠?



