use UIAppearance methods for customizing UIAlertView

混江龙づ霸主 提交于 2019-12-07 13:23:45

问题


I know that UIAlertView conforms to UIAppearance and UIAppearanceContainer.

But how do I use UIAppearance to customize/style UIAlertView? I am not able to find it over the net.


回答1:


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.




回答2:


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.




回答3:


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];
}];


来源:https://stackoverflow.com/questions/13928525/use-uiappearance-methods-for-customizing-uialertview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!