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("RakutenSansJP-Regular", 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("RakutenSansJP-Regular", 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:
Screen shoot 1
Screen shoot 2
Screen shoot 3
Screen shoot 4
Has anyone else encountered this issue or have any suggestions on how to resolve it?