【发布时间】:2012-12-05 09:31:25
【问题描述】:
我知道UIAlertView 符合UIAppearance 和UIAppearanceContainer。
但是我如何使用UIAppearance 自定义/样式UIAlertView?我无法通过网络找到它。
【问题讨论】:
标签: iphone ios customization uialertview uiappearance
我知道UIAlertView 符合UIAppearance 和UIAppearanceContainer。
但是我如何使用UIAppearance 自定义/样式UIAlertView?我无法通过网络找到它。
【问题讨论】:
标签: iphone ios customization uialertview uiappearance
如果你想自定义 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];
}];
【讨论】:
如果您想使用UIAlertView 功能、模态视图等...您可以对其进行子类化。
希望这会有所帮助。
【讨论】:
您不能使用UIAppearance 自定义UIAlertView。
UIAlertView 仅显示为具有UIAppearance,因为UIView 符合UIAppearance 并且UIAlertView 是UIView 的子类。
它实际上并没有实现它。
【讨论】: