我创建了一个简单的演示,仅创建了 UITabBarController 的子类并在故事板中设置。
我想在选择时将 TabBarButtonItem 的标题设置为橙色,在正常情况下将标题设置为黑色。以下代码在 iPhone 上的任何 iOS 版本上都可以正常工作,但在 iOS 15 的 iPad(设备和模拟器)上,所选颜色更改为蓝色和有线正常状态颜色。
这是苹果的错误还是我错过了什么?(我使用的是 Xcode13)
class CustomViewController: UITabBarController {
override func viewDidLoad() {
super.viewDidLoad()
let tabBarAppearnace = UITabBarAppearance()
let tabFont = UIFont.boldSystemFont(ofSize: 18)
let selectedAttributes: [NSAttributedString.Key: Any]
= [NSAttributedString.Key.font: tabFont, NSAttributedString.Key.foregroundColor: UIColor.orange]
let normalAttributes: [NSAttributedString.Key: Any]
= [NSAttributedString.Key.font: tabFont, NSAttributedString.Key.foregroundColor: UIColor.black]
tabBarAppearnace.stackedLayoutAppearance.normal.titleTextAttributes = normalAttributes
tabBarAppearnace.stackedLayoutAppearance.selected.titleTextAttributes = selectedAttributes
tabBar.standardAppearance = tabBarAppearnace
}
}
Run Code Online (Sandbox Code Playgroud)
当我使用 Xcode 14 时,我没有遇到任何警告。然而,更新到 Xcode 15 后,我突然开始收到来自第三方库的 200 多个警告。有谁知道这样做的原因或如何解决这些警告而不必等待库更新?这些警告似乎与库中 Objective-C 的使用有关。
类似这样的警告:
Mixed ObjC ABI, /Users/wanghong/Developer/alpaca/Pods/AppsFlyerFramework/iOS/AppsFlyerLib.framework/Versions/A/AppsFlyerLib[x86_64][26](AppsFlyerAES128Crypto.o) compiled with category class properties