Post

Replies

Boosts

Views

Activity

SwiftUI font size layout bug
This is an example of the view that has a glitch in layout. struct SomeSection: View { var body: some View { ZStack(alignment: .topTrailing) { VStack(spacing: 16) { Text("This is title\n with two lines") .font(.system(size: 24).bold()) .multilineTextAlignment(.center) Text("This is long description text\n that occupies more than 2 lines \n and in that case it causes a bug") .font(.system(size: 15)) .multilineTextAlignment(.center) } .background(Color.orange) Button { print("close") } label: { Image(systemName: "xmark") } .background(.green) } .background(.red) } } You can see red bar at the bottom that should not be visible. Top multilined label doesn't occupy necessary space and is trimmed. But if you change size of top label's font to 22 or LESS OR bottom label's font to 16 or MORE everything will look accordingly expectations. Can anyone explain why this happens and how to fix it?
0
0
219
Sep ’24