use UIAppearance methods for customizing UIAlertView

╄→尐↘猪︶ㄣ 提交于 2019-12-05 19:47:35

You can't use UIAppearance to customise UIAlertView.

UIAlertView only shows as having UIAppearance because UIView conforms to UIAppearance and UIAlertView is a subclass of UIView.

It doesn't actually implement it though.

If you want to use UIAlertView functionality, modally view, etc... you can subclass it.

Here an example: http://www.albertopasca.it/whiletrue/2012/07/objective-c-modal-view-navigation-tabbar-controller-projects/

hope this helps.

If you want to customize UIAlertView, i made subclass of UIAlertView, you can find it on github WCAlertView which support similiar proxy to UIAppearance. You can use it to set default appearce for all WCAlertView:

[WCAlertView setDefaultCustomiaztonBlock:^(WCAlertView *alertView) {
        alertView.labelTextColor = [UIColor colorWithRed:0.11f green:0.08f blue:0.39f alpha:1.00f];
        alertView.labelShadowColor = [UIColor whiteColor];

        UIColor *topGradient = [UIColor colorWithRed:1.0f green:1.0f blue:1.0f alpha:1.0f];
        UIColor *middleGradient = [UIColor colorWithRed:0.93f green:0.94f blue:0.96f alpha:1.0f];
        UIColor *bottomGradient = [UIColor colorWithRed:0.89f green:0.89f blue:0.92f alpha:1.00f];
        alertView.gradientColors = @[topGradient,middleGradient,bottomGradient];

        alertView.outerFrameColor = [UIColor colorWithRed:250.0f/255.0f green:250.0f/255.0f blue:250.0f/255.0f alpha:1.0f];

        alertView.buttonTextColor = [UIColor colorWithRed:0.11f green:0.08f blue:0.39f alpha:1.00f];
        alertView.buttonShadowColor = [UIColor whiteColor];
}];
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!