[day 20 ] SwiftUI Essentials-Creating and Combining Views

SwiftUI Essentials - Creating and Combining Views

这篇主要是官网的 SwiftUI 入门介绍,我这边主要

是在介绍之时顺便学,官网的教学其实蛮详细的,

做的也蛮有水平的。

https://ithelp.ithome.com.tw/upload/images/20211005/20092056FxTGPlIVo9.png

我这边只是大概记录下我学的过程。

就一般的创建新工程项目之後,进入设定的地方
https://ithelp.ithome.com.tw/upload/images/20211005/20092056AGGYONZiIV.png

就记得调成 SwiftUI 以及 SwiftUI 就可以了。

contentView.swift 的原始结构如下

import SwiftUI

struct ContentView: View {
    var body: some View {
        Text("Hello, World!")
            .padding()
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

接下来在 command 加上左键点及 text就可呼叫出菜单,类似下图。

https://ithelp.ithome.com.tw/upload/images/20211005/20092056p5JuqmXC2G.png

然後点击那个Show Swift UI啥的就可以了。
https://ithelp.ithome.com.tw/upload/images/20211005/20092056egpjRudJWb.png

调整的属性会以程序码的方式出现在文件中,类似这样

  Text("Turtle Rock")
  .font(.title)

布局啥的也是 command 加上左键就会出现相关的选项。

https://ithelp.ithome.com.tw/upload/images/20211005/20092056QnnzcdjnBv.png

这边就也是跟故事版一样右边+号就能加上 widget。

https://ithelp.ithome.com.tw/upload/images/20211005/20092056JEDudn0iWW.png

接下来就是算难一点点的增加客制化界面,就是最上图上面那个圆形的图案;

简单来说就是先增加的客制化的 Swift 界面,然後做好之後再放入主界面里面,

这个教学的就感觉蛮详细的,具体有兴趣的可以去看看,难度蛮低的。

SwiftUI Essentials - Creating and Combining Views


<<:  [DAY 20] 树耳朵 oh les feuilles

>>:  [2021铁人赛 Day20] General Skills 17

My experience with AWSome Day (Certification)

October 29, 2020 I’ve practiced the principle of M...

[Day 01] 什麽是 Kotlin Exposed?为什麽要介绍它?

大家好!这三十天,我们这系列文章会介绍 Kotlin Exposed 这个框架,并且和大家谈怎麽利用...

Day 23 bert 文字情感分类-2

在这里我们要将训练集替换成中文,但是原本资料集的资料夹格式如下: tf.keras.preproce...

Day 19 - 建立 canvas QRCode

前述 今天因为时间不足 T_T .... 所以教大家使用 qrcode.react ,可以很快速的产...

Google Apps Script 语言

Google Apps Script 语言 https://wolkesau.medium.com/...