Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
414 views
in Technique[技术] by (71.8m points)

Adjust SwiftUI Component from UIKit

Sometimes I any need to adjust the swiftUI component, so I dive into UIKit and adjust what I need, for example in the code below I adjust the table view appearance for a specific view, the problem is that effect to all the SwiftUI views the have table view so everything became a big mess, did there is some way to adjust the SwiftUI component for specific view without effect the same component in the other's views.

    struct New_EditGroup: View {
            
        init() {
            let tableAppearance = UITableView.appearance()
            tableAppearance.contentInset = UIEdgeInsets(top: 16, left: 0, bottom: 0, right: 0)
            tableAppearance.sectionHeaderHeight = 1
            tableAppearance.sectionFooterHeight = 16
            
        }
       
        var body: some View {
    // ...

enter image description here

enter image description here

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
struct ContentView: View {
    var body: some View {
        NavigationView {
            Form {
                Section(header: Spacer().frame(height: 16)) {
                    ForEach(1..<10) { element in
                        Text("Element (element)")
                    }
                }
            }
            .navigationBarTitle("Main Menu", displayMode: .inline)
        }
    }
}

Spacer


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...