What’s new in Xcode 14.3 & iOS 16.4

Andrii
2 min readFeb 20, 2023

--

Xcode logo. Xcode 14.3 & iOS 16.4

A couple of days ago, Apple introduced iOS 16.4 beta and Xcode 14.3 beta. Now I want to show you most interesting improvement for developers.

First of all, you need to check how to print in SwiftUI Preview

Xcode screen.

Interact with the View Behind the Sheet

This can be done with the .presentationBackgroundInteraction(.enabled) modifier.

You can click on the image at the back and get "Background tapped" print in the debug console.

struct ContentView: View {
@State private var isPresented = false
var body: some View {
ZStack(alignment: .top) {
Color(.orange)
.ignoresSafeArea()
.onTapGesture {
print("Background tapped")
}
Button {
isPresented = true
} label: {
Text("Open Sheet")
.font(.title)
}
.buttonStyle(.borderedProminent)
.tint(.black)
}
.sheet(isPresented: $isPresented) {
Text("Detail")
.presentationDetents([.medium, .large])
.presentationBackgroundInteraction(.enabled)
}
}
}

Translucent Sheet Background

You can make a sheet background translucent with the new .presentationBackground(_:) modifier. Uses the .ultraThinMaterial as the sheet background.

struct ContentView: View {
@State private var isPresented = false
var body: some View {
ZStack(alignment: .top) {
Color(.orange)
.ignoresSafeArea()
Button {
isPresented = true
} label: {
Text("Open Sheet")
.font(.title)
}
.buttonStyle(.borderedProminent)
.tint(.black)
}
.sheet(isPresented: $isPresented) {
Text("Hey, Medium!")
.presentationDetents([.medium, .large])
.presentationBackground(.ultraThinMaterial)
}
}
}

Sheet Corner Radius Setting

Already can change the corner radius of a sheet using .presentationCornerRadius( ) modifier.

struct ContentView: View {
@State private var isPresented = false
var body: some View {
ZStack(alignment: .top) {
Color(.orange)
.ignoresSafeArea()
Button {
isPresented = true
} label: {
Text("Open Sheet")
.font(.title)
}
.buttonStyle(.borderedProminent)
.tint(.black)
}
.sheet(isPresented: $isPresented) {
Text("Hey, Medium!")
.presentationDetents([.medium, .large])
.presentationCornerRadius(40)
}
}
}

Controlling Scroll and Expand Behavior

Now we can use .presentationContentInteraction(.scrolls) to make scrolling take precedence over the sheet resizing.

struct ContentView: View {
@State private var isPresented = false
var body: some View {
ZStack(alignment: .top) {
Color(.orange)
.ignoresSafeArea()
Button {
isPresented = true
} label: {
Text("Open Sheet")
.font(.title)
}
.buttonStyle(.borderedProminent)
.tint(.black)
}
.sheet(isPresented: $isPresented) {
List(0..<30) { i in
Text(i.description)
}
.presentationDetents([.medium, .large])
.presentationContentInteraction(.scrolls)
}
}
}

Function Back Deployment

The @backDeployed(before:) attribute is used to extend the availability of a function to OS releases prior to the introduction of that function as ABI.

@available(macOS 12, *)
public struct Temperature {
public var degreesCelsius: Double

// ...
}

extension Temperature {
@available(macOS 12, *)
@backDeployed(before: macOS 13)

public var degreesFahrenheit: Double {
return (degreesCelsius
- 9 / 5) + 32
}
}

Hope this was useful for you. Thanks for reading!

--

--

Andrii
Andrii

Written by Andrii

Debunker ❌ | iOS developer 👨🏻‍💻| Apple fun 🍏

Responses (1)