【问题标题】:UIButton appearance setBackgroundColor effecting navigation bar now after updateUIButton 外观 setBackgroundColor 更新后现在影响导航栏
【发布时间】:2018-01-14 14:46:04
【问题描述】:

Xcode 或 iOS 更新使以下代码的功能有所不同,因为现在导航栏按钮背景具有背景颜色,与以前不同。有什么修复吗?我希望所有按钮都具有相同的全局颜色,但现在它会影响我不想要的导航栏按钮。我希望它像以前一样透明。

[[UIButton appearance] setBackgroundColor:[Helper getColor:self.application.color]];

【问题讨论】:

    标签: ios objective-c xcode uibutton


    【解决方案1】:

    由于此特定 UIButton 位于 UINavigationBar 内,您可以尝试应用第二个特定外观来“覆盖”第一个常规外观集。 比如具体调用,

    [[UIButton appearanceWhenContainedIn:[UINavigationBar class], nil]
           setBackgroundColor:[UIColor clearColor] forState:state barMetrics:metrics];
    

    打电话后

    [[UIButton appearance] setBackgroundColor:[Helper getColor:self.application.color]];
    

    用具体覆盖一般。

    文档链接:https://developer.apple.com/documentation/uikit/uiappearance

    【讨论】:

    • 救命稻草...尽管[[UIButton appearanceWhenContainedIn:[UINavigationBar class], nil] setBackgroundColor:nil]; 我还是走这条路
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-21
    • 1970-01-01
    相关资源
    最近更新 更多