1. increaseUISheetPresentationController, through which you can control the display size of Modal UIViewController, and you can switch between different sizes by dragging and dropping gestures. Just do the following on the target UIViewController:
if let presentationController = presentationController as? UISheetPresentationController {
       // The supported size for display
       presentationController.detents = [.medium(), .large()]
       // Display an indicator indicating that you can drag to resize
       presentationController.prefersGrabberVisible = true
}
Copy the code
  1. UIButtonSupports more configurations.UIButton.ConfigurationIs a new structure that specifies the appearance and behavior of the button and its contents. It has a number of properties related to the appearance and content of the button, such asCornerStyle, baseForegroundColor, baseBackgroundColor, buttonSize, title, Image, Subtitle, titlePadding, imagePadding, contentIns Ets, imagePlacementAnd so on.
// Plain
let plain = UIButton(configuration: .plain(), primaryAction: nil)
plain.setTitle("Plain", for: .normal)
// Gray
let gray = UIButton(configuration: .gray(), primaryAction: nil)
gray.setTitle("Gray", for: .normal)
// Tinted
let tinted = UIButton(configuration: .tinted(), primaryAction: nil)
tinted.setTitle("Tinted", for: .normal)
// Filled
let filled = UIButton(configuration: .filled(), primaryAction: nil)
filled.setTitle("Filled", for: .normal) 
Copy the code

  1. launchCLLocationButtonUsed for one-time location authorization, which is built inCoreLocationUIModule, but you still need to use it if you need to get the location detailsCoreLocation.
let locationButton = CLLocationButton(a)/ / text
locationButton.label = .currentLocation
locationButton.fontSize = 20
/ / icon
locationButton.icon = .arrowFilled
/ / the rounded
locationButton.cornerRadius = 10
// tint
locationButton.tintColor = UIColor.systemPink
/ / the background color
locationButton.backgroundColor = UIColor.systemGreen
// Click the event in which the location request should be made
locationButton.addTarget(self, action: #selector(getCurrentLocation), for: .touchUpInside)
Copy the code
  1. URLSession introduces apis that support async/await, including fetching data, uploading, and downloading.
let session = URLSession.shared
// Load the data
let (data, response) = try await session.data(from: url)
/ / download
let (localURL, _) = try await session.download(from: url)
/ / upload
let (_, response) = try await session.upload(for: request, from: data)
Copy the code
  1. System image support multiple layers, support a variety of rendering modes.
HierarchicalColor: Renders multiple layers with different opacity
let config = UIImage.SymbolConfiguration(hierarchicalColor: .systemRed)
let image = UIImage(systemName: "square.stack.3d.down.right.fill", withConfiguration: config)
// paletteColors: render multiple layers and set different styles
let config2 = UIImage.SymbolConfiguration(paletteColors: [.systemRed, .systemGreen, .systemBlue])
let image2 = UIImage(systemName: "person.3.sequence.fill", withConfiguration: config2)
Copy the code
  1. To set colors for UINavigationBar, UIToolbar, and UITabBar, use the UIBarAppearance APIs.
// UINavigationBar
let navigationBarAppearance = UINavigationBarAppearance()
navigationBarAppearance.backgroundColor = .red
navigationController?.navigationBar.scrollEdgeAppearance = navigationBarAppearance
navigationController?.navigationBar.standardAppearance = navigationBarAppearance
// UIToolbar
let toolBarAppearance = UIToolbarAppearance()
toolBarAppearance.backgroundColor = .blue
navigationController?.toolbar.scrollEdgeAppearance = toolBarAppearance
navigationController?.toolbar.standardAppearance = toolBarAppearance
// UITabBar
let tabBarAppearance = UITabBarAppearance()
toolBarAppearance.backgroundColor = .purple
tabBarController?.tabBar.scrollEdgeAppearance = tabBarAppearance
tabBarController?.tabBar.standardAppearance = tabBarAppearance
Copy the code
  1. UITableView has a new property, sectionHeaderTopPadding, which adds a default height to each section header.
tableView.sectionHeaderTopPadding = 0
Copy the code
  1. UIImage has several new resizing methods.
// preparingThumbnail
UIImage(named: "sv.png")?.preparingThumbnail(of: CGSize(width: 200, height: 100))
PrepareThumbnail, get the adjusted UIImage directly in the closure
UIImage(named: "sv.png")?.prepareThumbnail(of: CGSize(width: 200, height: 100)) { image in
        // Need to go back to the main thread to update the UI
}
// byPreparingThumbnail
await UIImage(named: "sv.png")?.byPreparingThumbnail(ofSize: CGSize(width: 100, height: 100))
Copy the code

The code in the article has been tested in Xcode 13 Beta3, the case source codeDownload address.