简体   繁体   中英

SwiftUI buttons change text size at appear

在此处输入图像描述

As can be seen in the GIF, the "Done" button text becomes larger as soon as the sheet is completely open. This not only happens in this view, but also in others which use systemimages instead of text. Does anyone know a solution to the problem or do I do something wrong? I'm still relive new with Swift.

    NavigationView {
        Form {
            ...
        }
        .toolbar {
            ToolbarItem(placement: ToolbarItemPlacement.navigationBarLeading) {
                Button(action: {
                    self.showSheet = false
                }) {
                    Text("Done")
                        .bold()
                }
            }
        }
    }

You can set font type to avoid this size changing behaviour.

Button(action: {
   self.showSheet = false
}) {
   Text("Done")
        .font(.headline)
        .bold()
}

This is now solved in iOS 16 beta. (Both public and developer beta)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM