记录iOS 13.0 遇到的坑

1、WKWebView 加载 “http://xxx”。

// iOS 13.0 新增allowsExpensiveNetworkAccess。
guard let url = URL(string: "http://www.baidu.com") else { return }
var request = URLRequest(url: url)
if #available(iOS 13.0, *) {
   request.allowsExpensiveNetworkAccess = true
}
self.mWebView.load(request)

2、UITabBarItem的文字颜色。当push到新界面,再返回tabbar的界面时,文字颜色变成了默认的蓝色。

// 把这段代码放到 你的 UITabBarController 的 viewDidLoad方法里面
if #available(iOS 13.0, *) {
    let itemAppear = UITabBarItemAppearance(style: .stacked)
    // XMColor 是自定义的颜色 struct。
    itemAppear.normal.titleTextAttributes = [NSAttributedString.Key.foregroundColor: XMColor.gray102]
    itemAppear.selected.titleTextAttributes = [NSAttributedString.Key.foregroundColor: XMColor.orange]
    
    let appear = UITabBarAppearance()
    appear.stackedLayoutAppearance = itemAppear
    // tabBar 是 UITabBarController 的属性
    tabBar.standardAppearance = appear
}

 

你可能感兴趣的:(工作笔记)