Tap Sudoku
In final stream in this miniseries about making games with SwiftUI, we’re going to create a mini sudoku game from scratch. It’s pretty packed, but a fantastic starting point for ...
环境(一) – 从环境中读取
环境 (environment) 本质上,它是⼀种内置的依赖注⼊ (dependency injection) 技术。 下⾯这个例⼦中,当我们在 VStack 上设置字体时,它会传播到两个 Text 视图中去,并改变它们的外观: Font ...
语法(四) – 懒加载
懒加载是统性能优化的方式之一。 懒加载闭包 基本语法,如下所示 lazy var yourVariableName: SomeType = { return SomeType(whatever: 'foobar') }() 懒加载闭包代码示例 class Singer { let n...
类型(六) – 泛型
func inspect<T>(_ value: T) { print('Received \(type(of: value)) with the value \(value)') } inspect('Haters gonna hate') inspect(56) 限制泛型 func square<T: Numeric>(_...
布局(一) – 布局算法
布局的具体算法描述如下:父视图向子视图提供一个建议尺寸。⼦视图基于这个建议尺⼨决定⾃⼰的尺⼨,如果这个⼦视图还有⾃⼰的⼦视图,从步骤 1 开始递归。⼦视图将它的尺⼨报告给⽗视图。⽗视图...








