• SwiftUI 九


    • SwiftUI - init

    SwiftUI 中init方法,会在编译期进行预加载

    init() {
     }
    • List样式设置init方法中预onAppear中的区别
    // 全局生效,以项目中最后加载的init方法中的设置为准
     init() {
                UITableView.appearance().sectionFooterHeight = 10
                UITableView.appearance().backgroundColor = UIColor.red
                UITableViewCell.appearance().backgroundColor = UIColor.red
    
            }
    
    
    // 当前页面生效
    .onAppear() {
                    UITableView.appearance().sectionFooterHeight = 10
                    UITableView.appearance().backgroundColor = UIColor.red
                    UITableViewCell.appearance().backgroundColor = UIColor.red
                }
    • List自定义组尾视图
    struct Footer: View {
        var body: some View {
            Rectangle()
                .foregroundColor(.white)
                .listRowInsets(EdgeInsets())
        }
    }
    
    struct Timeline : View {
        var body: some View {
            List {
                Section(footer: Footer()) {
                    Text("Item 1")
                    Text("Item 2")
                    Text("Item 3")
                }
            }
        }
    }
    
    
    List {
             Section(footer: Text(""))) {
                    Text("One")
                    Text("Two")
                    Text("Three")
                }
         }
    
    
    List {
        Section(footer: Text("")) {
            Text("My text")
        }
        EmptyView()
    }
    
    List {
        Text("Item 1")
        Text("Item 2")
    
        // Adding empty section with footer
        Section(footer:
            Rectangle()
                .foregroundColor(.clear)
                .background(Color(.systemBackground))){EmptyView()}
                .padding(.horizontal, -15)
    }
  • 相关阅读:
    常量/静态常量
    git github仓库
    内存泄漏/溢出
    console线和RJ45
    Medium
    教师群
    编程入门学习网站
    科技传播坊公众号
    科技传播坊直播课堂 Scratch
    Scratch 疑难杂症视频
  • 原文地址:https://www.cnblogs.com/liuxiaokun/p/12677018.html
Copyright © 2020-2023  润新知