【问题标题】:UIAlertview valueForKey:@"_backgroundImageView"UIAlertview valueForKey:@"_backgroundImageView"
【发布时间】:2013-10-25 01:55:57
【问题描述】:

我想更改 ui alert view 的文本颜色和背景颜色。我正在使用以下代码, UILabel *theTitle = [alertView valueForKey:@"_titleLabel"]; [theTitle setTextColor:[UIColor whiteColor]];

    UILabel *theBody = [alertView valueForKey:@"_bodyTextLabel"];
    [theBody setTextColor:[UIColor whiteColor]];


  UIImageView *backgroundImageView = (UIImageView *)[alertView valueForKey:@"_backgroundImageView"];
   [backgroundImageView setImage:[UIImage imageNamed:@"background.png"]];

这在 ios 6 中运行良好。但升级到 ios 7 后,此方法不起作用。我不想创建自定义 uialertview。请提出任何简单的解决方案来解决此问题。

【问题讨论】:

    标签: ios uialertview


    【解决方案1】:

    从 iOS7 开始,UIAlertViews 不再可自定义。

    您必须坚持他们的风格,或者从 UIView 创建自己的风格,但您无法改变这一点。

    【讨论】:

      【解决方案2】:

      在 iOS7 中,UIAlertView 只不过是一个数据容器。它只接受您设置的参数并将它们显示在私有窗口上的私有视图层次结构中。您的警报视图永远不会添加到任何视图层次结构中。

      要么推出你自己的警报视图实现,要么使用开源的,比如 DTAlertView:https://www.cocoacontrols.com/controls/dtalertview

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-06-28
        • 1970-01-01
        • 1970-01-01
        • 2013-04-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2010-11-06
        相关资源
        最近更新 更多