Giter Site home page Giter Site logo

swiftui-tutorials's Introduction

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

  • macOS 10.15 beta 或更高
  • Xcode 11.0 beta 或更高

概述

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

🎉 SwiftUI 教程(中文)

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

觉得不错?给个 Star 或 Follow 👌

调整

图片

为了优化阅读体验,部分图片加上了 #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)
    }
}
...

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

License

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

swiftui-tutorials's People

Contributors

williewangwei avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.