use UIAppearance methods for customizing UIAlertVi

2019-05-10 19:44发布

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.

3条回答
▲ chillily
2楼-- · 2019-05-10 20:10

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.

查看更多
Evening l夕情丶
3楼-- · 2019-05-10 20:22

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];
}];
查看更多
Evening l夕情丶
4楼-- · 2019-05-10 20:23

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.

查看更多
登录 后发表回答