fatalError("Unable to access the current UIViewController.") } // iOS26
navigationBar.prefersLargeTitles = true // iOS26新增 navigationItem.largeTitle = "导航" UIBarButtonItem(barButtonSystemItem: .compose, target: self, action: #selector(handleEvent)) // iOS26 新增 barButtonItemOne.badge = .count(10) // iOS26新增 barButtonItemFour.style = . prominent // iOS26新增 let fixedSpace = UIBarButtonItem.fixedSpace(20) let flexibleSpace
0.5 slider.addTarget(self, action: #selector(valueChanged), for: .valueChanged) // iOS26 新增 slider.sliderStyle = .default // iOS26新增,刻度数量 var config = UISlider.TrackConfiguration action: #selector(valueChanged), for: .valueChanged) slider.sliderStyle = .thumbless // iOS26
tabs.append(configSearchTab(UIViewController(), title: "搜索")) selectedTab = tabs.last // iOS26 只显示第一个与UISearchTab的图标,中间显示辅助UITabAccessory self.tabBarMinimizeBehavior = .onScrollDown // iOS26
CGRect(x: 150, y: 100, width: 100, height: 200)) view.backgroundColor = .systemRed // iOS26 UIView = { let view = UIView(frame: CGRect(x: 150, y: 340, width: 100, height: 100)) // iOS26 CGRect(x: 150, y: 480, width: 100, height: 100)) view.backgroundColor = .systemBlue // iOS26
scrollView.addSubview(contentView) scrollView.contentSize = contentView.frame.size // iOS26 stackView.spacing = 16 stackView.translatesAutoresizingMaskIntoConstraints = false // iOS26
systemTeal glassEffect() } // MARK: UIGlassEffect func glassEffect() { // iOS26 let label = UILabel(frame: CGRect(x: 0, y: 0, width: 100, height: 50)) label.text = "iOS26 glassContainerEffect() } // MARK: UIGlassContainerEffect func glassContainerEffect() { // iOS26
UIViewController { let configs: [UIButton.Configuration] = { [ { // iOS26 systemName: "heart") return config }(), { // iOS26 systemName: "star") return config }(), { // iOS26 square.and.arrow.up") return config }(), { // iOS26 config.preferredSymbolConfigurationForImage = UIImage.SymbolConfiguration(pointSize: 50, weight: .thin) // iOS26
setToolbarHidden(false, animated: false) // iOS26新增,允许将searchBar集成到UIToolbar navigationItem.searchBarPlacementAllowsToolbarIntegration
ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() // iOS26 UIColorWell = { let colorWell = UIColorWell() colorWell.title = "设置背景色" // iOS26 新增 colorWell.maximumLinearExposure = 2.0 // iOS26新增,是否支持吸取颜色 colorWell.supportsEyedropper colorPickerViewController.title = "颜色选择器" colorPickerViewController.delegate = self // iOS26 新增 colorPickerViewController.maximumLinearExposure = 2.0 // iOS26新增 colorPickerViewController.supportsEyedropper
新增了一种新的动画选项flushUpdates,它可以自动根据 @Observable Object 或者 AutoLayout 约束的更改添加动画效果,而无需手动调用layoutIfNeeded()方法。
在 iOS 开发中,有时会遇到这样一种需求:应用内有一些文件格式本身不被当前 App 支持,但我们希望能够通过系统调用,将这些文件交给其他 App 打开,如 .zip、.docx 或 .pdf 文件。在 iOS 26 之后,通过 UIScene 的 open(_:options:completionHandler:) 方法,可以非常方便地实现这一功能。
{ model.currentColor = .systemBlue model.currentValue = "iOS26" } } 效果 手动更新 案例 import { model.currentColor = .systemGray model.currentValue = "iOS26" // 手动更新
Xcode 支持 ChatGPT 等 LLM 服务(其他服务商需要提供 API 密钥)与本地 LLM,开发者可以直接使用它们辅助编码、测试,修错等工作。通过 Xcode 菜单 —> Xcode —> Settings... —> Intelligence 可以进行详细设置,调用时左下角会出现对话窗口。但该功能要求操作系统为 macOS 26 及以上。
在 WWDC25 上 Apple 推出了 Xcode 26,相比较 Xcode 16,它有如下的变化。