【问题标题】:UIColor patternImage conflict with UIActivityViewController barTintColorUIColor patternImage 与 UIActivityViewController barTintColor 冲突
【发布时间】:2015-08-04 16:40:02
【问题描述】:

我正在使用UIColor(patternImage:) 来改变UINavigationBar 的颜色,就像那样

UINavigationBar.appearance().barTintColor = UIColor(patternImage: UIImage(named: "Bar")!)

但是当我尝试使用 UIActivityViewController 在 Facebook 或 Twitter 上分享时,我收到了错误Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Only RGBA or White color spaces are supported in this situation

有没有其他方法可以实现这一点?

* 更新 *

目前唯一可行的解​​决方案是更改所有 ViewController 中的每个 UINavigationBar 色调

self.navigationController?.navigationBar.barTintColor = UIColor(patternImage: UIImage(named: "Bar")!)

【问题讨论】:

    标签: ios swift uinavigationbar uicolor uiactivityviewcontroller


    【解决方案1】:

    尝试导航外观方法。

    UIApplication.sharedApplication().statusBarStyle = UIStatusBarStyle.LightContent
    
        UINavigationBar.appearance().setBackgroundImage(UIImage(named: "navBg.png"), forBarMetrics: UIBarMetrics.Default)
        UINavigationBar.appearance().translucent = false
        UINavigationBar.appearance().tintColor = UIColor.lightGrayColor()
    

    注意:图片高度保持 64 像素。希望对您有所帮助。

    在 info.plist 中添加 key 查看基于控制器的状态栏外观 = NO

    【讨论】:

    • 我之前已经尝试过了,但这个解决方案只会影响栏背景,它会使状态栏变黑
    • 还是不行,statusBar看起来和导航栏完全分开了
    • 我很好地测试了这项工作。您可以通过创建新项目来尝试。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-04-29
    • 1970-01-01
    • 2017-12-09
    • 2013-10-21
    • 2020-08-19
    • 2010-12-10
    • 2018-04-02
    相关资源
    最近更新 更多