iOS 13新特性

iOS 13新特性

  1. view controller presentwindows

    iOS 13以後,present的modalPresentationStyle方式變成了automatic, 呈現的方式並非全屏顯示,而是會頂部留白,默認下拉能夠dismiss。app

    若是想要全屏顯示能夠以下:spa

    vc.modalPresentationStyle = .fullScreen
     self.present(vc, animated: true)
    複製代碼
  2. 禁用暗黑模式code

    將info.plist的UserInterfaceStyle的value設置爲lightip

  3. iOS 13中禁用KVC調用私有屬性get

    好比:string

    let searchField: UITextField = self.searchBar.value(forKey: "")
    	let placeHolderLabel: UILabel = searchField.value(forKey: "placeHolderLabel")
     placeHolderLabel.textColor = UIColor.red
    複製代碼

    上面這個會引發crash,正確的作法:it

    let textField = self.searchBar.searchTextField // in iOS 13
     let attr = NSMutableAttributedString(string: "aaaa")
     textField?.attributedPlaceholder = attr
    複製代碼
  4. keyWindowio

    iOS 13爲了適配多屛,若是是多屏的應用的話,那麼:table

    UIApplication.shared.keyWindow 
    複製代碼

    就不該該再被使用

    @available(iOS, introduced: 2.0, deprecated: 13.0, message: "Should not be used for applications that support multiple scenes as it returns a key window across all connected scenes")
     open var keyWindow: UIWindow? { get }
    複製代碼

    取而代之的應該是:

    UIApplication.shared.windows.filter { $0.isKeyWindow }.first複製代碼
相關文章
相關標籤/搜索