swiftui标注

inlinePresentationIntent = .softBreak

 

inlinePresentationIntent = .softBreak
//行距
.baselineOffset = 20

enum 样式 {
        case 重要, 风险, important
    }
    @State var 成长样式 = 样式.重要

 var attributeContainer: AttributeContainer {
      var container = AttributeContainer()
      switch 成长样式 {
      case .重要:
        container.font = .custom("Menlo", size: 17, relativeTo: .body)
          container.foregroundColor = .red.opacity(0.75)
          container.backgroundColor = .yellow.opacity(0.15)
      case .风险:
          container.foregroundColor = .teal
          container.font = .headline
          container.inlinePresentationIntent = .softBreak
      default:
        break
      }
      return container
    }

text[range].mergeAttributes(attributeContainer)

 

 

 

.baselineOffset = 20

 @State private var timer = Timer.publish(every: 1, on: .main, in: .common).autoconnect()

posted @ 2022-07-25 19:13  速搞  阅读(35)  评论(0)    收藏  举报