Sunday, December 15, 2024
HomeiOS Developmentios - Additional Area on the Backside of Textual content in Multiline...

ios – Additional Area on the Backside of Textual content in Multiline TextField with Customized Font in SwiftUI


I am encountering a difficulty in SwiftUI when utilizing a customized font in a TextField with the axis property set to .vertical. Particularly, there’s additional area on the backside of the textual content within the TextField. This drawback doesn’t happen when the axis is about to .horizontal, nor does it happen when utilizing the system font.

Right here is my code:

VStack(spacing: DSConstants.Spacing.spacing16) {
    Textual content("Axis: Horizontal")
    TextField("", textual content: $textual content, axis: .horizontal)
        .font(.customized("RakutenSansJP-Common", dimension: 14))
        .body(minHeight: 44)
        .centered($modifying)
        .padding(.horizontal, 16)
        .padding(.vertical, 4)
        .background(
            RoundedRectangle(cornerRadius: 16)
                .fill(Shade.white)
        )
        .overlay(
            RoundedRectangle(cornerRadius: 16)
                .stroke(modifying ? Shade.blue : Shade.grey, lineWidth: 1)
        )
        .centered($modifying)
    
    Textual content("Axis: Vertical")
    TextField("", textual content: $textual content, axis: .vertical)
        .font(.customized("RakutenSansJP-Common", dimension: 14))
        .body(minHeight: 44)
        .centered($modifying)
        .padding(.horizontal, 16)
        .padding(.vertical, 4)
        .background(
            RoundedRectangle(cornerRadius: 16)
                .fill(Shade.white)
        )
        .overlay(
            RoundedRectangle(cornerRadius: 16)
                .stroke(modifying ? Shade.blue : Shade.grey, lineWidth: 1)
        )
        .centered($modifying)
}

Display screen shot:

Display screen shoot 1

Display screen shoot 2

Display screen shoot 3

Display screen shoot 4

Has anybody else encountered this situation or have any strategies on find out how to resolve it?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments