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

2020 SwiftUI & UI Frameworks

WWDC20 · 30 min · SwiftUI & UI Frameworks

Modern cell configuration

Discover new techniques for configuring collection view and table view cells to quickly build dynamic interfaces in your app. Explore configuration types you can use to easily populate cells with content and apply common styles. Take advantage of powerful APIs to customize the appearance of cells for different states. Find out about patterns and best practices that simplify your code, eliminate bugs, and improve performance.

Watch at developer.apple.com ↗

Transcript all transcripts

Code shown on screen · 6 snippets

Configuring a UITableViewCell swift · at 1:31 ↗
cell.imageView?.image = UIImage(systemName: "star")
cell.textLabel?.text = "Hello WWDC!"
Configuring a UITableViewCell Using a Content Configuration swift · at 1:59 ↗
var content = cell.defaultContentConfiguration()

content.image = UIImage(systemName: "star")
content.text = "Hello WWDC!"

cell.contentConfiguration = content
Updating Configurations swift · at 13:10 ↗
let updatedConfiguration = configuration.updated(for: state)
Customizing Appearance for Different States swift · at 16:33 ↗
override func updateConfiguration(using state: UICellConfigurationState) {
    var content = self.defaultContentConfiguration().updated(for: state)
    
    content.image = self.item.icon
    content.text = self.item.title
 
    if state.isHighlighted || state.isSelected {
        content.imageProperties.tintColor = .white
        content.textProperties.color = .white
    }
 
    self.contentConfiguration = content
}
Default Configurations swift · at 19:45 ↗
var background = UIBackgroundConfiguration.listSidebarCell()

var content = UIListContentConfiguration.sidebarCell()
Creating a List Content View swift · at 26:23 ↗
var content = UIListContentConfiguration.cell()

// Set up the content configuration as desired...

let contentView = UIListContentView(configuration: content)

Resources