Xcode — SwiftUI

文档 #

SwiftUI | Apple Developer Documentation

基础概念 #

Layout fundamentals

声明式语法 #

1. 不透明的返回值类型 #

2. 省略 return #

3. 尾随闭包 #

4. function builder #

举例来说,vstack 定义:

init(alignment: HorizontalAlignment = .center, spacing: CGFloat? = nil, content: () -> Content)

vstack 使用:

struct PracticeView: View {
    var body: some View {
        VStack{
            Text("HELLO")
            Text("hello")
        }
    }
}

数据状态(Model Data) #

SwiftUI 对数据流与状态的管理

Scene #

A part of an app’s user interface with a life cycle managed by the system.

WindowGroup #

A scene that presents a group of identically structured windows.

Views #

WindowGroup #

Button #

keyboardShortcut #

disabled #

数据持久化 #

AppStorage #

UserDefaults #

参考 Foundation

参考资料 #

本文共 215 字,上次修改于 Dec 6, 2024
相关标签: Swift, Xcode, ByAI, SwiftUI