I am using capsules in my application and the size of the capsules depends on integers. I want the size of the capsule to have a maximum height of 250 so I set the maxHeight: 250
and the idealHeight: height
(the height is set to CGFloat var height : CGFloat
). So when I run the program the height is sometimes greater than 250 and I get an error Contradictory frame constraints specified.
Can I ignore this error and if not can you please help me. Here is my code if it helps. Thanks for your attention. Iām looking forward to your reply.
let heightPoint : [[Int]] = [
[300, 50],
[130,76],
[86,287],
[130,23]
]
return VStack {
Picker(selection: $selected, label: Text("")) {
Text("Daily").tag(0)
Text("Weekly").tag(1)
Text("Monthly").tag(2)
Text("Yearly").tag(3)
}
.padding(25)
.pickerStyle(SegmentedPickerStyle())
Spacer()
HStack(alignment: .bottom) {
BarChart(height: CGFloat(heightPoint[selected][0]))
BarChart(height: CGFloat(heightPoint[selected][1]))
}
.animation(.easeInOut)
}
.frame(height: 300)
}
}
struct BarChart : View {
var height : CGFloat
var body: some View {
Capsule()
.frame(maxWidth: 20, idealHeight: height, maxHeight: 250)
.foregroundColor(Color.green)
}
}