1.29 SwiftUI学习笔记

1.29 SwiftUI学习笔记,第1张

1.Form

A container for grouping controls used for data entry, such as in settings or inspectors.

对用于数据输入的控件(如设置或检查器)进行分组的容器

用法:

var body: some View {
        Form {
            Section(header: Text("Notifications")) {
                Picker("Notify Me About", selection: $notifyMeAbout) {
                    Text("Direct Messages").tag(NotifyMeAboutType.directMessages)
                    Text("Mentions").tag(NotifyMeAboutType.mentions)
                    Text("Anything").tag(NotifyMeAboutType.anything)
                }
                Toggle("Play notification sounds", isOn: $playNotificationSounds)
                Toggle("Send read receipts", isOn: $sendReadReceipts)
            }
            Section(header: Text("User Profiles")) {
                Picker("Profile Image Size", selection: $profileImageSize) {
                    Text("Large").tag(ProfileImageSize.large)
                    Text("Medium").tag(ProfileImageSize.medium)
                    Text("Small").tag(ProfileImageSize.small)
                }
                Button("Clear Image Cache") {}
            }
        }
    
}

2.Future

A publisher that eventually produces a single value and then finishes or fails.

最终生成单个值,之后成功或失败 的 发布者

Future.Promise

A type that represents a closure to invoke in the future, when an element or error is available.、当元素或错误可用时,表示将来要调用的闭包 的类型

typealias Promise = (Result) -> Void

3.eraseToAnyPublisher() 

用来将类型擦除,最后得到一个AnyPublisher类型的发布者

​
func eraseToAnyPublisher() -> AnyPublisher

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/993853.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-21
下一篇 2022-05-21

发表评论

登录后才能评论

评论列表(0条)

保存