Post

Replies

Boosts

Views

Activity

Reply to Computed property for Shape within the SwiftUI's views
Thank you very much @BabyJ! I see now. It's actually a little bit confusing (the part that Ellipse and RoundedRectangle both confirm to Shape but could not be easily used in the .background modifier). But what do you think about the performance of the approach which used AnyShape? I also figured out, that what I want to achieve can be done with a @ViewBuilder like this: @ViewBuilder var shape: some View { if isEllipsis { color.clipShape(Ellipse()) } else { color.clipShape(RoundedRectangle(cornerRadius: 8)) } } and then the following usage of it in the .background: .background(shape) I'm not sure that this will perform better then AnyShape nor not sure that I used @ViewBuilder in a right way (I still don't understand how it works). But I would be very appreciate if you give your opinion on this. Thanks again!
Topic: UI Frameworks SubTopic: SwiftUI
Jun ’25