UIActionSheet按钮的颜色 [英] UIActionSheet button's color

查看:119
本文介绍了UIActionSheet按钮的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何更改UIActionSheet按钮的颜色?

How can I change the color of UIActionSheet button's color?

推荐答案

iOS 8(UIAlertController)

如果你使用的是UIAlertController,超级简单。只需更改UIAlertController视图上的色调。

It's super simple to do if you're using a UIAlertController. Simply change the tint color on the view of the UIAlertController.

[alertController.view setTintColor:[UIColor red];

iOS 7(UIActionSheet)

我通过这个简单的方法成功地改变了文本的颜色。

I successfully change the text color by using this simple method.

- (void) changeTextColorForUIActionSheet:(UIActionSheet*)actionSheet {
    UIColor *tintColor = [UIColor redColor];

    NSArray *actionSheetButtons = actionSheet.subviews;
    for (int i = 0; [actionSheetButtons count] > i; i++) {
        UIView *view = (UIView*)[actionSheetButtons objectAtIndex:i];
        if([view isKindOfClass:[UIButton class]]){
            UIButton *btn = (UIButton*)view;
            [btn setTitleColor:tintColor forState:UIControlStateNormal];

        }
    }
}

要运行此 AFTER ,您可以致电

[actionSheet showInView];

如果在[showInView]之前调用它,则除了取消按钮之外的所有按钮都将被着色。希望这有助于某人!

If you call it before [showInView], all buttons but the cancel button will be colored. Hope this helps someone!

这篇关于UIActionSheet按钮的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆