SwiftUI

A collection of 37 posts
SwiftUI|使用 sensoryFeedback 添加触感反馈
SwiftUI

SwiftUI|使用 sensoryFeedback 添加触感反馈

UIImpactFeedbackGenerator UIImpactFeedbackGenerator 是 UIKit 提供的一个组件,可以用于精细的控制反馈类型。 UIKit 不支持 macOS 和 tvOS,因此,考虑到跨平台性,不建议使用它。 sensoryFeedback 基于选择状态的反馈(.selection) * 用户在设置中,切换深色/浅色模式 .sensoryFeedback(.selection, trigger: colorScheme) * 拖动项目重新排序列表时感受到的触觉反馈 .alignment 基于操作结果的反馈(.success) 告诉用户操作是否成功或出现了错误: .sensoryFeedback(.success, trigger: isActionPerformed) .sensoryFeedback(.error, trigger: isActionPerformed) .sensoryFeedback(.warning, trigger: isActionPerformed) 自定义反馈效果(.impac
2 min read
使用 iOS 18 上的自适应 TabView 标签栏
SwiftUI

使用 iOS 18 上的自适应 TabView 标签栏

Tabview 是从 iOS13 开始被引入的 SwiftUI 组件,用于创建在多个子视图之间切换的视图。在 WWDC 2024 中,苹果对 TabView 的功能和使用方法进行了多项改进,在本文中,我们将了解新版本中的新功能及其改进之处。 Enhancing your app’s content with tab navigation | Apple Developer DocumentationKeep your app content front and center while providing quick access to navigation using the tab bar.Apple Developer Documentation Tabview 核心改进 * 编程控制 * 自适应平台
4 min read