2 Star 23 Fork 10

小弟调调/swiftui-example

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
.github
.idoc
assets
example
accessibility
advanced-state
alerts-and-menus
animation
appendix-a
composing-views
containers
cross-platform
data
drawing
forms
images-shapes-media
introduction
lists
presenting-views
quick-start
answering-the-big-question-should-you-learn-swiftui-uikit-or-both.md
dedication.md
dont-panic.md
frequently-asked-questions-about-swiftui.md
how-to-follow-this-quick-start-guide.md
migrating-from-uikit-to-swiftui.md
swiftui-vs-interface-builder-and-storyboards.md
what-is-swiftui.md
whats-in-the-basic-template.md
responding-to-events
stacks-grids-scrollviews
taps-and-gestures
tooling
transforming-views
user-interface-controls
view-layout
working-with-static-text
cheat-sheet.md
.gitattributes
.gitignore
LICENSE
README.md
idoc.chapters.yml
idoc.yml
package.json
renovate.json
克隆/下载
migrating-from-uikit-to-swiftui.md 1.62 KB
一键复制 编辑 原始数据 按行查看 历史
小弟调调 提交于 4年前 . doc: Fix error. #25

从 UIKit 迁移到 SwiftUI

Updated for Xcode 13 New in macOS 12

如果你以前使用过 UIKit,你所知道和喜爱的许多类,只要去掉 UI 的前缀,就可以直接映射到它们的SwiftUI 等价物。这并不意味着它们在本质上是一样的,只是它们有相同或相似的功能。

这里有一个列表可以让你开始,UIKit 类的名字后面是 SwiftUI 的名字:

  • UITableView: List
  • UICollectionView: LazyVGrid and LazyHGrid
  • UILabel: Text
  • UITextField: TextField
  • UITextField with isSecureTextEntry set to true: SecureField
  • UITextView: TextEditor (plain strings only)
  • UISwitch: Toggle
  • UISlider: Slider
  • UIButton: Button
  • UINavigationController: NavigationView
  • UIAlertController with style .alert: Alert
  • UIAlertController with style .actionSheet: ActionSheet
  • UIStackView with horizontal axis: HStack
  • UIStackView with vertical axis: VStack
  • UIImageView: Image
  • UISegmentedControl: Picker
  • UIStepper: Stepper
  • UIDatePicker: DatePicker
  • UIProgressView: ProgressView with a value
  • UIActivityIndicatorView: ProgressView without a value
  • NSAttributedString: Incompatible with SwiftUI; use Text instead.

还有许多其他的组件是 SwiftUI 独有的,比如说堆栈视图(stack view),它让我们可以按深度而不是按水平或垂直方向来构建东西。

Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Swift
1
https://gitee.com/jaywcjlove/swiftui-example.git
git@gitee.com:jaywcjlove/swiftui-example.git
jaywcjlove
swiftui-example
swiftui-example
main

搜索帮助