DJ-*_*ock 4 ios uiappearance swift swift4
我正在尝试更改我的应用程序中所有标签的默认文本颜色.我曾尝试使用UILabel.appearance().textColor,但它不适用于我.有人可以告诉我做错了什么吗?我已经检查了很多关于SO的问题,最新的问题是这个.根据描述,它是可用的.
如果我改变了背景颜色 - 它有效.试图改变tintColor - 没有效果.为什么?是从UIAppearance协议中删除了吗?
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate {
var window: UIWindow?
var smStore: SMStore?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// UIAppearance configuring
let tintColor = UIColor.white
//let backgroundColor = UIColor(red: 5, green: 72, blue: 149, alpha: 1)
let backgroundColor = UIColor.black
// Global tintColor
window?.tintColor = tintColor
// UIViews
UIView.appearance().tintColor = tintColor
UIView.appearance().backgroundColor = backgroundColor
// UINavigationBars
UINavigationBar.appearance().tintColor = tintColor
UINavigationBar.appearance().backgroundColor = tintColor
// UITableViews
UITableView.appearance().backgroundColor = backgroundColor
UITableViewCell.appearance().backgroundColor = backgroundColor
UITableViewCell.appearance().tintColor = tintColor
// UILabels
UILabel.appearance().backgroundColor = UIColor.green
...
}
Run Code Online (Sandbox Code Playgroud)
XCode 9,Swift 4.
rma*_*ddy 15
只需键入它.它编译.
UILabel.appearance().textColor = .red
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1375 次 |
| 最近记录: |