使用UIAppearance方法自定义UIAlertView
我知道UIAlertView
符合UIAppearance
和UIAppearanceContainer
。
但是如何使用UIAppearance
来定制/设计UIAlertView
? 我无法通过网络找到它。
您无法使用UIAppearance
来自定义UIAlertView
。
UIAlertView
仅显示为具有UIAppearance
因为UIView
符合UIAppearance
而UIAlertView
是UIView
的子类。
它实际上并没有实现它。
如果你想使用UIAlertView
function,模态视图等…你可以将它子类化。
这是一个例子: http : //www.albertopasca.it/whiletrue/2012/07/objective-c-modal-view-navigation-tabbar-controller-projects/
希望这可以帮助。
如果你想自定义UIAlertView,我做了UIAlertView的子类,你可以在github WCAlertView上找到它,它支持UIAppearance的类似代理。 您可以使用它来设置所有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]; }];