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