文档 #
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) #
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