1、UIScrollView增加了屬性allowsKeyboardScrolling表示是否根據連接的物理鍵盤的方向鍵而滾動。 import UIKit class ViewController: UIViewController { lazy var scrollView: UIScrollVie ...
1、UIScrollView
增加了屬性
allowsKeyboardScrolling
表示是否根據連接的物理鍵盤的方向鍵而滾動。
import UIKit class ViewController: UIViewController { lazy var scrollView: UIScrollView = { let scrollView = UIScrollView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.width)) let imageView = UIImageView(image: UIImage(named: "img")) scrollView.addSubview(imageView) scrollView.contentSize = imageView.bounds.size // iOS17新增,預設為true scrollView.isScrollEnabled = false return scrollView }() override func viewDidLoad() { super.viewDidLoad() view.addSubview(scrollView) } }
2、applicationIconBadgeNumber
UIApplication 的applicationIconBadgeNumber
屬性被廢棄,建議使用UNUserNotificationCenter.current().setBadgeCount()
方法。
import UIKit import UserNotifications class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() } override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { // iOS17之後設置角標,需要先授權 // UNUserNotificationCenter.current().setBadgeCount(10) UNUserNotificationCenter.current().setBadgeCount(10) { error in if let error { print(error) } } } }
3、UIDocumentViewController
新增視圖控制器,用於顯示與管理本地或者雲端文檔。
import UIKit class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() } override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { let documentViewController = UIDocumentViewController() documentViewController.openDocument { _ in print("打開文檔") } present(documentViewController, animated: true) } }
4、UIHoverStyle
UIView 增加了一個hoverStyle
屬性,可以設置滑鼠移動到 UIView 之上的效果。
import UIKit class ViewController: UIViewController { lazy var redView: UIView = { let view = UIView(frame: CGRect(x: 200, y: 200, width: 200, height: 200)) view.backgroundColor = .red // iOS17新增UIHoverStyle,可以設置Hover的效果與形狀(UIShape) let hoverStyle = UIHoverStyle(effect: .lift, shape: .capsule) // iOS17新增,滑鼠移動到UIView之上的效果 view.hoverStyle = hoverStyle return view }() override func viewDidLoad() { super.viewDidLoad() view.addSubview(redView) } }
5、編譯報錯cfstring constant not pointer aligned
解決辦法:Build Settings -> Other Linker Flags 加入-ld64
6、編譯報錯Sandbox:rsync.sanba deny(1) file-write-create xxx
使用 Xcode15 新建項目後,pod 引入部分第三方會報上面的錯誤
解決辦法:Build Settings 搜索 sandbox,把 Build Options 中的 User Script Sandboxing改為 NO
7、編譯報錯UIGraphicsBeginImageContextWithOptions崩潰
參考鏈接:UIGraphicsBeginImageContext Deprecated
YYText使用時會崩潰在UIGraphicsBeginImageContextWithOptions