SwiftUI – how to avoid navigation hardcoded into the view?

The closure is all you need! struct ItemsView<Destination: View>: View { let items: [Item] let buildDestination: (Item) -> Destination var body: some View { NavigationView { List(items) { item in NavigationLink(destination: self.buildDestination(item)) { Text(item.id.uuidString) } } } } } I wrote a post about replacing the delegate pattern in SwiftUI with closures. https://swiftwithmajid.com/2019/11/06/the-power-of-closures-in-swiftui/

How to remove the line separators from a List in SwiftUI without using ForEach?

iOS 15: This year Apple introduced a new modifier .listRowSeparator that can be used to style the separators. you can pass .hidden to hide it: List { ForEach(items, id:\.self) { Text(“Row \($0)”) .listRowSeparator(.hidden) } } iOS 14: you may consider using a LazyVStack inside a ScrollView instead (because iOS is NOT supporting UIAppearance for SwiftUI … Read more

Include SwiftUI views in existing UIKit application

edit 05/06/19: Added information about UIHostingController as suggested by @Departamento B in his answer. Credits go to him! Using SwiftUI within UIKit One can use SwiftUI components in existing UIKit environments by wrapping a SwiftUI View into a UIHostingController like this: let swiftUIView = SomeSwiftUIView() // swiftUIView is View let viewCtrl = UIHostingController(rootView: swiftUIView) It’s … Read more

Round Specific Corners SwiftUI

Using as a custom modifier You can use it like a normal modifier: .cornerRadius(20, corners: [.topLeft, .bottomRight]) Demo You need to implement a simple extension on View like this: extension View { func cornerRadius(_ radius: CGFloat, corners: UIRectCorner) -> some View { clipShape( RoundedCorner(radius: radius, corners: corners) ) } } And here is the struct … Read more