I'm encountering an issue in SwiftUI when using a custom font in a TextField with the axis property set to .vertical. Specifically, there is extra space at the bottom of the text in the TextField. This problem does not occur when the axis is set to .horizontal, nor does it occur when using the system font.
Here is my code:
VStack(spacing: DSConstants.Spacing.spacing16) {
Text("Axis: Horizontal")
TextField("", text: $text, axis: .horizontal)
.font(.custom("MyCustomFont", size: 14))
.frame(minHeight: 44)
.focused($editing)
.padding(.horizontal, 16)
.padding(.vertical, 4)
.background(
RoundedRectangle(cornerRadius: 16)
.fill(Color.white)
)
.overlay(
RoundedRectangle(cornerRadius: 16)
.stroke(editing ? Color.blue : Color.gray, lineWidth: 1)
)
.focused($editing)
Text("Axis: Vertical")
TextField("", text: $text, axis: .vertical)
.font(.custom("MyCustomFont", size: 14))
.frame(minHeight: 44)
.focused($editing)
.padding(.horizontal, 16)
.padding(.vertical, 4)
.background(
RoundedRectangle(cornerRadius: 16)
.fill(Color.white)
)
.overlay(
RoundedRectangle(cornerRadius: 16)
.stroke(editing ? Color.blue : Color.gray, lineWidth: 1)
)
.focused($editing)
}
Screen shot:
Has anyone else encountered this issue or have any suggestions on how to resolve it?
Post
Replies
Boosts
Views
Activity
I'm experiencing an issue where my app freezes when built with Xcode 16 on iOS 18.
Additional Information:
The issue does not occur when building the app with Xcode 16 on iOS 17 or lower.
The issue does not occur when building the app with Xcode 15 on iOS 18.
The CPU usage spikes to 100% when the app freezes.
The app specifically freezes after the code runs into .sink(receiveValue:).
Here is the relevant code snippet:
@Published var selectedCardData: CardData?
@Published var selectedRootTab: RootViewTab = .statement
override func load() {
state = .loading
$selectedCardData.ignoreNil()
.removeDuplicates()
.map { [unowned self] cardData in
$selectedRootTab.filter { $0 == .statement }
.first()
.map { _ in cardData }
}
.switchToLatest()
.sink(receiveValue: { value in
print(value) // value not nil
print("Execution reaches this point and the app freezes (CPU 100%).")
})
.store(in: &cancellables)
}
Are there any known changes in iOS 18 or Xcode 16 that might affect this code?