xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

SwiftUI All In One

SwiftUI

SwiftUI is an innovative, exceptionally simple way to build user interfaces across all Apple platforms with the power of Swift.
Build user interfaces for any Apple device using just one set of tools and APIs.
With a declarative Swift syntax that’s easy to read and natural to write, SwiftUI works seamlessly with new Xcode design tools to keep your code and design perfectly in sync.
Automatic support for Dynamic Type, Dark Mode, localization, and accessibility means your first line of SwiftUI code is already the most powerful UI code you’ve ever written.

SwiftUI是一种创新的,非常简单的方法,可以借助Swift跨所有Apple平台构建用户界面。
仅使用一组工具和API为任何Apple设备构建用户界面。
SwiftUI具有易于阅读且易于编写的声明式Swift语法,可与新的Xcode设计工具无缝协作,以使您的代码和设计完美同步。
自动支持动态类型,暗模式,本地化和可访问性,这意味着您的SwiftUI代码的第一行已经是您编写过的功能最强大的UI代码。

Xcode 11.5

https://developer.apple.com/xcode/swiftui/

声明式语法

设计工具

在所有 Apple平台上都是原生

SwiftUI 快捷键

https://developer.apple.com/tutorials/swiftui/creating-and-combining-views

  1. Command + Click

In the preview, Command-click the greeting to bring up the structured editing popover, and choose Inspect.

open the inspector by Command-clicking on the Text declaration in the code editor

View Stack


struct ContentView: View {
  var body: some View {
    Text("Turtle Rock")
      .font(.title)
      .multilineTextAlignment(.center)
      .brightness(0.0)
  }
}

You can combine and embed multiple views in stacks, which group views together horizontally, vertically, or back-to-front.

  1. HStack

horizontally

import SwiftUI

struct ContentView: View {
  var body: some View {
    HStack {
      Text("Turtle Rock")
        .font(.title)
        .multilineTextAlignment(.center)
        .brightness(0.0)
    }
  }
}

  1. VStack

vertically

struct ContentView: View {
  var body: some View {
    VStack {
      Text("Turtle Rock")
        .font(.title)
        .multilineTextAlignment(.center)
        .brightness(0.0)
    }
  }
}

back-to-front








docs

https://developer.apple.com/documentation/swiftui/


refs

https://zzk.cnblogs.com/my/s/blogpost-p?Keywords=SwiftUI

https://github.com/xgqfrms/swift/tree/gh-pages/100-days-of-swiftui

https://www.hackingwithswift.com/100/swiftui

https://www.youtube.com/playlist?list=PLuoeXyslFTuZRi4q4VT6lZKxYbr7so1Mr

https://www.youtube.com/playlist?list=PLuoeXyslFTuaZtX7xSYbWz3TR0Vpz39gK

what's SwiftUI

https://www.hackingwithswift.com/quick-start/swiftui/what-is-swiftui



©xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!


原文地址:https://www.cnblogs.com/xgqfrms/p/13887724.html