Post

Replies

Boosts

Views

Activity

Reply to swift ui magic
here is a solution: struct TestView: View { var body: some View { Text("description") .clipShape(getShape(position: .middle)) } } struct TestView_Previews: PreviewProvider { static var previews: some View { ContentView() } } enum ElementPosition { case first case middle } func getShape(position: ElementPosition) -> some Shape { switch position { case .first: return AnyShape(Circle()) case .middle: return AnyShape(Rectangle()) } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’23
Reply to swift ui magic
here is a solution: struct TestView: View { var body: some View { Text("description") .clipShape(getShape(position: .middle)) } } struct TestView_Previews: PreviewProvider { static var previews: some View { ContentView() } } enum ElementPosition { case first case middle } func getShape(position: ElementPosition) -> some Shape { switch position { case .first: return AnyShape(Circle()) case .middle: return AnyShape(Rectangle()) } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Aug ’23