UIActionSheet(或UIAlertView)的tintColor(iOS 7)

是否可以在iOS 7的tintColor颜色的UIActionSheet中使用按钮?我的意思是如果我的应用程序是品牌tintColor,例如红色,我不想在行动表中使用蓝色按钮.与UIAlertView相同.

解决方法

我想强调这违反了Apple的规则,但这有效:
- (void)willPresentActionSheet:(UIActionSheet *)actionSheet
{
    [actionSheet.subviews enumerateObjectsUsingBlock:^(UIView *subview,NSUInteger idx,BOOL *stop) {
        if ([subview isKindOfClass:[UIButton class]]) {
            UIButton *button = (UIButton *)subview;
            button.titleLabel.textColor = [UIColor greenColor];
            Nsstring *buttonText = button.titleLabel.text;
            if ([buttonText isEqualToString:NSLocalizedString(@"Cancel",nil)]) {
               [button setTitleColor:[UIColor greenColor] forState:UIControlStatenormal];
            }
        }
    }];
}

(符合UIActionSheetDelegate)

尚未尝试过UIAlertView.

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...