SwiftUI 组件参数简写 All In One


SwiftUI 组件参数简写 All In One

Button


  VStack {
    Button(
      action: {
        print("click button")
      },
      label: {
        Text("CTO ??")
          .font(Font.largeTitle)
          .fontWeight(.heavy)
      }
    )
    // 等价于
    Button(action: {
      print("click button")
    }) {
      Text("CTO")
      .font(Font.largeTitle)
      .fontWeight(.heavy)
    }
  }

API

struct Button

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

fontWeight

Font Weights

static let black: Font.Weight
static let bold: Font.Weight
static let heavy: Font.Weight
static let light: Font.Weight
static let medium: Font.Weight
static let regular: Font.Weight
static let semibold: Font.Weight
static let thin: Font.Weight
static let ultraLight: Font.Weight

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

https://developer.apple.com/documentation/swiftui/text/fontweight(_:)

font

Standard Fonts


static let largeTitle: Font
A font with the large title text style.
static let title: Font
A font with the title text style.
static let title2: Font
Create a font for second level hierarchical headings.
static let title3: Font
Create a font for third level hierarchical headings.
static let headline: Font
A font with the headline text style.
static let subheadline: Font
A font with the subheadline text style.
static let body: Font
A font with the body text style.
static let callout: Font
A font with the callout text style.
static let caption: Font
A font with the caption text style.
static let caption2: Font
Create a font with the alternate caption text style.
static let footnote: Font
A font with the footnote text style.
Getting System Fonts


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

refs

https://www.hackingwithswift.com/quick-start/swiftui/how-to-create-a-tappable-button

https://stackoverflow.com/questions/57047994/how-can-i-change-my-font-weight-to-medium-in-swiftui


Flag Counter

?xgqfrms 2012-2020

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

原创文章,版权所有??xgqfrms, 禁止转载 ???,侵权必究??!