0

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)
    }

}
Abion47
  • 22,211
  • 4
  • 65
  • 88
NYBSZ37
  • 61
  • 7
  • If it's a warning you can probably ignore it (though it's generally unwise to do so). If it really is an error, you can't (and shouldn't) just ignore it. – Abion47 Aug 07 '20 at 21:23
  • @Abion47 It's warning because the app still runs I just don't know if it will cause crashes. Anyhow thanks for the suggestion I will try to correct it. – NYBSZ37 Aug 07 '20 at 21:47

0 Answers0