Zurück zum Ranking

WillieWangWei/SwiftUI-Tutorials

Swiftgithub.com/WillieWangWei/SwiftUI-Tutorials

A code example and translation project of SwiftUI. / 一个 SwiftUI 的示例、翻译的教程项目。

swiftuiswiftswiftui-exampleswiftuiexaswiftui-animationsexamlpestranslationchinesechinese-translationcombinetutorialuiframework
Sterne-Wachstum
Sterne
2.5k
Forks
315
Wochenwachstum
Issues
4
1k2k
Juni 2019Okt. 2021März 2024Juli 2026
README

构建示例项目需要以下环境:

  • macOS 10.15 Catalina 或更高
  • Xcode 11.1 或更高

概述

对于初步学习和使用 SwiftUI 的开发者来说,官方教程无疑是最好的范例。它以构建一个 App 为脉络,串联出了 SwiftUI 重要的知识点,并主动抛出开发中一些常见的问题,然后用 SwiftUI 给出了解决方案。通过阅读此教程,你将逐步获得使用 SwiftUI 开发 App 的技能和思想。

此项目为 SwiftUI Tutorials 的翻译及代码示例,具体内容请翻阅:

🎉 SwiftUI 教程(中文)

项目中的代码为完成所有教程后的最终成品,你可以直接体验多种 SwiftUI 特性。另外,你也可以在每个教程章节中下载对应的起始和完成代码。

完成本教程,你将获得一个这样的 App 以及一套精彩的 SwiftUI 代码:

平台 预览
iOS
watchOS
macOS

觉得不错?给个 Star 或 Follow 👌

更新日志

版本 内容
v1.0.0 完成初版
v1.0.1 同步官方文档
增加成品预览
v1.0.2 同步官方文档
优化翻译,修复翻译错误,让阅读更流畅
增加了代码高亮
标记出了代码修改范围,便于上下文对比
v1.0.3 新增章节《创建 watchOS App》
修复代码bug
增加 watchOS App 成品预览
v1.0.4 同步官方文档
v1.0.5 添加 Wiki 子模块
v1.0.6 新增章节《创建 macOS App》

调整

图片

为了优化阅读体验,部分图片加上了 #000000 50% 10 Blur 的阴影。

视频

由于 GitHub Wiki 的限制,所有视频已转码成 GIF

代码

在实际编码中,由于本地环境和官方教程不一致,导致部分方法的声明和调用方式、代码风格等与官方教程有细微出入,例如:

官方教程:

.
.
.
struct MapView: UIViewRepresentable {
    func makeUIView(context: Context) -> MKMapView {
        MKMapView(frame: .zero)
    }
}
.
.
.

这里的 UIViewRepresentable 是一个协议,它的声明中包含一个 associatedtype :

/// The type of `UIView` to be presented.
associatedtype UIViewType : UIView

在开发中,给此 associatedtype 赋值后 Xcode 对方法的签名补全会有变化,最终写作:

.
.
.
struct MapView : UIViewRepresentable {
    
    typealias UIViewType = MKMapView
    
    func makeUIView(context: UIViewRepresentableContext<MapView>) -> MKMapView {
        return MKMapView(frame: .zero)
    }
}
.
.
.

如此修改不再一一列举,只需记得此类修改不会改变原教程的构建结果即可,不必过于纠结。

微信技术群

SwiftUI 代表未来构建 App 的方向,欢迎加群一起交流技术,解决问题。

加群现在需要申请了,可以先加我微信,备注 "SwiftUI",我会拉你进群。

Stargazers over time

Sparkline

Stargazers over time

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Ähnliche Repositories
dkhamsing/open-source-ios-apps

:iphone: Collaborative List of Open-Source iOS Apps

Creative Commons Zero v1.0 Universaliosswift
51.3k6k
jordanbaird/Ice

Powerful menu bar manager for macOS

SwiftGNU General Public License v3.0macosmenubar
icemenubar.app
29k824
NativeScript/NativeScript

⚡ Write Native with TypeScript ✨ Best of all worlds (TypeScript, Swift, Objective C, Kotlin, Java, Dart). Use what you love ❤️ Angular, React, Solid, Svelte, Vue with: iOS (UIKit, SwiftUI), Android (View, Jetpack Compose), Flutter and you name it compatible.

TypeScriptnpmMIT Licensenativescriptandroid
nativescript.org
25.6k1.7k
CodeEditApp/CodeEdit

📝 CodeEdit App for macOS – Elevate your code editing experience. Open source, free forever.

SwiftMIT Licensemacosapple
codeedit.app
23k1.2k
Whisky-App/Whisky

A modern Wine wrapper for macOS built with SwiftUI

SwiftGNU General Public License v3.0macosswiftui
getwhisky.app
15.2k603
pointfreeco/swift-composable-architecture

A library for building applications in a consistent and understandable way, with composition, testing, and ergonomics in mind.

SwiftMIT Licensearchitecturecomposition
pointfree.co/collections/composable-architecture
14.8k1.7k
mrkai77/Loop

Window management made elegant.

SwiftGNU General Public License v3.0macosswift
11.2k254
gao-sun/eul

🖥️ macOS status monitoring app written in SwiftUI.

SwiftMIT Licensemacosmonitoring
9.9k373
stonerl/Thaw

Menu bar manager for macOS 26

SwiftGNU General Public License v3.0macosmacos-app
8.9k207
sindresorhus/Gifski

🌈 Convert videos to high-quality GIFs on your Mac

SwiftMIT Licensegifskigif
sindresorhus.com/gifski
8.5k320
XcodesOrg/XcodesApp

The easiest way to install and switch between multiple versions of Xcode - with a mouse click.

SwiftMIT Licensexcodeswift
xcodes.app
8.5k376
ronitsingh10/FineTune

FineTune, a macOS menu bar app for per-app volume control, multi-device output, audio routing, and 10-band EQ. Free and open-source alternative to SoundSource.

SwiftGNU General Public License v3.0audioaudio-utility
8.2k280