Change Text Color of Items in UIActionSheet - iOS 8

前端 未结 9 1402
星月不相逢
星月不相逢 2020-11-29 02:26

I had been using following code to change text color of items which I add in UIActionSheet.:

- (void)willPresentActionSheet:(UIActionSheet *)act         


        
9条回答
  •  时光取名叫无心
    2020-11-29 02:47

    For iOS 7 backwards compatibility, and to collect the proper default tint colour (that Apple may well change in future versions), I use this. Thanks to the answers about default tint and to Lucas's answer above.

        const Class alertControllerClass = NSClassFromString(@"UIAlertController");
        if(alertControllerClass)
        {
            UIColor *defaultTintColour = UIView.new.tintColor;
            [[UIView appearanceWhenContainedIn: alertControllerClass, nil] setTintColor: defaultTintColour];
        }
    

    Caution though – you need to ensure that you use this before you start setting the global tint otherwise the UIView.new.tintColor will just give you the current tint you have set up.

提交回复
热议问题