gpt4 book ai didi

ios - 在 NavBar 中将 tintColor 更改为默认值(蓝色)

转载 作者:行者123 更新时间:2023-11-29 01:14:27 27 4
gpt4 key购买 nike

我可以在设置 Pane 中更改我的应用程序(任何地方)的tintColor。当我更改tintColor,然后尝试返回到默认色调颜色时,导航栏中的某些按钮不会返回蓝色,我该如何处理这个问题?

验证:- 创建一个新项目主/详细信息- 在详细 View 中:添加两个按钮,名称为:“红色界面”和“蓝色界面”- 在 DetailViewController 中,添加操作

@IBAction func tapRed(sender: AnyObject) {
view.window!.tintColor = UIColor.redColor()
}


@IBAction func tapBlue(sender: AnyObject) {
view.window!.tintColor = nil
}

现在运行应用程序,创建时间戳,转到详细信息,点击红色界面,然后点击蓝色界面在详细信息 View 中这没问题,但是当您返回到主视图时,“+”按钮项目是红色的,而不是蓝色的。

我可以通过设置真正的蓝色而不是零来解决这个问题,但这不是一个长期的解决方案,如果苹果改变默认的tintColor。

这是一个错误吗?我可以做些什么来绕过这个问题吗?

最佳答案

一个快速的解决方法是在初始应用加载时获取默认色调并将其存储在某处(即用户默认值中)

来自苹果的iOS 7 UI Transition Guide (特别是在 Using Tint Color 部分下)。

By default, a view’s tint color is nil, which means that the view uses its parent’s tint. It also means that when you ask a view for its tint color, it always returns a color value, even if you haven’t set one.

关于ios - 在 NavBar 中将 tintColor 更改为默认值(蓝色),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35395823/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com