Trying to get a Text View to keep a minimum width for short strings... but it seems to ignore minWidth and idealWidth when any frame is stated. Taking the frame out of the picture, everything works as expected. Xcode 13.4.1, getting exact same result on Mac Catalyst, made for iPad, iPad and iPhone. Target is iOS 15.4 Am I just misunderstanding min/ideal/max ?
struct QuickTest: View {
func viewSizeReader() -> some View {
return GeometryReader { geometry -> Color in
let rect = geometry.frame(in: .local); print(rect); return .clear }}
var body: some View {
VStack(spacing: 0) {
HStack(spacing: 0) {
Text("A very looooong string to test with")
.frame(minWidth: 5, idealWidth: 5, maxWidth: 100, alignment: .leading)
.lineLimit(1)
.border(.red, width: 1)
.background(viewSizeReader())
Text("short")
.frame(minWidth: 5, idealWidth: 5, maxWidth: 100, alignment: .leading)
.lineLimit(1)
.border(.red, width: 1)
.background(viewSizeReader())
Spacer()
}
Spacer()
}
}
}