【问题标题】:use UIAppearance methods for customizing UIAlertView使用 UIAppearance 方法自定义 UIAlertView
【发布时间】:2012-12-05 09:31:25
【问题描述】:

我知道UIAlertView 符合UIAppearanceUIAppearanceContainer

但是我如何使用UIAppearance 自定义/样式UIAlertView?我无法通过网络找到它。

【问题讨论】:

    标签: iphone ios customization uialertview uiappearance


    【解决方案1】:

    如果你想自定义 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];
    }];
    

    【讨论】:

    【解决方案2】:

    如果您想使用UIAlertView 功能、模态视图等...您可以对其进行子类化。

    这里是一个例子: http://www.albertopasca.it/whiletrue/2012/07/objective-c-modal-view-navigation-tabbar-controller-projects/

    希望这会有所帮助。

    【讨论】:

      【解决方案3】:

      您不能使用UIAppearance 自定义UIAlertView

      UIAlertView 仅显示为具有UIAppearance,因为UIView 符合UIAppearance 并且UIAlertViewUIView 的子类。

      它实际上并没有实现它。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-06-06
        • 1970-01-01
        • 2012-01-09
        • 2010-10-07
        • 2011-10-14
        • 2011-05-10
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多