Dunfey · Hotel WWDC as data, est. 1983
Front desk everything
Years
Topics

2021 EssentialsSwiftUI & UI Frameworks

WWDC21 · 27 min · Essentials / SwiftUI & UI Frameworks

What’s new in UIKit

Discover the latest updates and improvements to UIKit and learn how to build better iPadOS, iOS, and Mac Catalyst apps. We’ll take you through UI refinements, productivity updates, and API enhancements, and help you explore performance improvements and security & privacy features.

Watch at developer.apple.com ↗

Transcript all transcripts

Code shown on screen · 8 snippets

Building an "Open in New Window" action swift · at 1:41 ↗
// Building an "Open in New Window" action

let newSceneAction = UIWindowScene.ActivationAction({ _ in

    // Create the user activity that represents the new scene content
    let userActivity = NSUserActivity(activityType: "com.myapp.detailscene")

    // Return the activation configuration
    return UIWindowScene.ActivationConfiguration(userActivity: userActivity)

})
UIMenuBuilder swift · at 3:06 ↗
class AppDelegate: UIResponder, UIApplicationDelegate {

    override func buildMenu(with builder: UIMenuBuilder) {
      
        // Use the builder to modify the main menu...
    }
}
UIBarAppearance swift · at 6:26 ↗
let appearance = UITabBarAppearance()
appearance.backgroundEffect = nil
appearance.backgroundColor = .blue

tabBar.scrollEdgeAppearance = appearance


let scrollView = ... // Content scroll view in your app
viewController.setContentScrollView(scrollView, for: .bottom)
Creating a button with UIButton.Configuration swift · at 11:31 ↗
// Creating a button with UIButton.Configuration

var config = UIButton.Configuration.tinted()

config.title = "Add to Cart"
config.image = UIImage(systemName: "cart.badge.plus")
config.imagePlacement = .trailing
config.buttonSize = .large
config.cornerStyle = .capsule

self.addToCartButton = UIButton(configuration: config)
Using a hierarchical color symbol swift · at 13:30 ↗
// Using a hierarchical color symbol

let configuration = UIImage.SymbolConfiguration(
    hierarchicalColor: UIColor.systemOrange
)

let image = UIImage(
    systemName: "sun.max.circle.fill",
    withConfiguration: configuration
)
New UICollectionViewCell.configurationUpdateHandler closures swift · at 19:30 ↗
// New UICollectionViewCell.configurationUpdateHandler closures

let cell: UICollectionViewCell = ...

cell.configurationUpdateHandler = { cell, state in
    var content = UIListContentConfiguration.cell().updated(for: state)
    content.text = "Hello world!"
    if state.isDisabled {
        content.textProperties.color = .systemGray
    }
    cell.contentConfiguration = content
}
Image display preparation swift · at 21:01 ↗
// Image display preparation

if let image = UIImage(contentsOfFile: pathToImage) {
    // Prepare the image for display asynchronously.
    Task {
        let preparedImage = await image.byPreparingForDisplay()

        imageView.image = preparedImage
    }
}
Image thumbnailing swift · at 21:29 ↗
// Image thumbnailing

if let bigImage = UIImage(contentsOfFile: pathToBigImage) {
    // Prepare the thumbnail asynchronously.
    Task {
        let smallImage = await bigImage.byPreparingThumbnail(ofSize: smallSize)

        imageView.image = smallImage
    }
}

Resources