戴铭

Results 93 issues of 戴铭

支持了 window,可以控制位置和大小。官方代码示例 [Bringing multiple windows to your SwiftUI app](https://developer.apple.com/documentation/swiftui/bringing_multiple_windows_to_your_swiftui_app) openWindow 代码示例如下: ```swift struct PartyPlanner: App { var body: some Scene { WindowGroup("Party Planner") { PartyPlannerHome() } Window("Party Budget", id: "budget")...

SF Symbol 支持变量值,可以通过设置 variableValue 来填充不同部分,比如 wifi 图标,不同值会亮不同部分,`Image(systemName: "wifi", variableValue: 0.5)` 。

今年 iOS 和 iPadOS 也可以使用去年只能在 macOS 上使用的 Table了,据 digital lounges 里说,iOS table 的性能和 list 差不多,table 默认为 plian list。我想 iOS 上加上 table 只是为了兼容 macOS 代码吧。 table 使用示例如下: ```swift Table(attendeeStore.attendees) { TableColumn("Name")...

Form 今年也得到了增强,示例如下: ```swift Form { Section { LabeledContent("Location") { AddressView(location) } DatePicker("Date", selection: $date) TextField("Description", text: $eventDescription, axis: .vertical) .lineLimit(3, reservesSpace: true) } Section("Vibe") { Picker("Accent color", selection: $accent) {...

ShareLink 视图可以让你轻松共享数据。示例代码如下: ```swift struct PShareLink: View { let url = URL(string: "https://ming1016.github.io/")! var body: some View { ShareLink(item: url, message: Text("戴铭的博客")) ShareLink("戴铭的博客", item: url) ShareLink(item: url) { Label("戴铭的博客", systemImage: "swift")...

Transferable 协议使数据可以用于剪切板、拖放和 Share Sheet。 可以在自己应用程序之间或你的应用和其他应用之间发送或接受可传输项目。 支持 SwiftUI 来使用。 官方文档 [Core Transferable](https://developer.apple.com/documentation/CoreTransferable) session [Meet Transferable](https://developer.apple.com/videos/play/wwdc2022-10062) 新增一个专门用来接受 Transferable 的按钮视图 PasteButton,使用示例如下: ```swift struct PPasteButton: View { @State private var s = "戴铭" var...

session [Compose custom layouts with SwiftUI](https://developer.apple.com/videos/play/wwdc2022-10056) 提供了新的 Grid 视图来同时满足 VStack 和 HStack。还有一个更低级别 Layout 接口,可以完全控制构建应用所需的布局。另外还有 ViewThatFits 可以自动选择填充可用空间的方式。 Grid 示例代码如下: ```swift Grid { GridRow { Text("One") Text("One") Text("One") } GridRow { Text("Two")...

可视化数据,使用 SwiftUI 语法来创建。还可以使用 ChartRenderer 接口将图标渲染成图。 官方文档 [Swift Charts](https://developer.apple.com/documentation/Charts) 入门参看 [Hello Swift Charts](https://developer.apple.com/videos/play/wwdc2022/10136/) Apple 文章 [Creating a chart using Swift Charts](https://developer.apple.com/documentation/Charts/Creating-a-chart-using-Swift-Charts) 高级定制和创建更精细图表,可以看这个 session [Swift Charts: Raise the bar](https://developer.apple.com/videos/play/wwdc2022/10137) 这个 session 也会提到如何在图表中进行交互。这里是...

- [WWDC22 SwiftUI 和 UI 库相关专题](https://developer.apple.com/wwdc22/topics/swiftui-ui-frameworks/) - 官方教程 [Learnning SwiftUI](https://developer.apple.com/tutorials/swiftui-concepts) - [SwiftUI 主题](https://developer.apple.com/xcode/swiftui/) - [SwiftUI Session](https://developer.apple.com/videos/swiftui-ui-frameworks) - [SwiftUI 文档](https://developer.apple.com/documentation/SwiftUI) - [Learning SwiftUI](https://developer.apple.com/tutorials/swiftui-concepts) 一年一度官方入门教程 - [Food Truck: Building a SwiftUI multiplatform...

[Improve app size and runtime performance](https://developer.apple.com/videos/play/wwdc2022/110363) 今年苹果通过更有效的检查 Swift 协议,使 OC 消息发送调用更小,使 autorelease elision 更快更小这几个个方面来让 App 体积更小,性能更高。 Swift 协议检查。 一个协议通过 as 操作符检查传递值是否符合协议,这种检查会在编译器的构建时间被优化掉,所以往往需要在运行时借助之前计算协议检查元数据来看对象是否真的符合了协议。一些元数据是在编译时建的,但还有很多元数据只能在启动时建立,特别是使用泛型时。协议多了,会增加耗时,差不多会多一半启动时间。 今年 Apple 推出新的 Swift 运行时,可以提前计算 Swift 协议元数据,作为 App 可执行文件和它在启动时使用的任何动态库的...