【问题标题】:How to resize Text View in Swift如何在 Swift 中调整文本视图的大小
【发布时间】:2021-12-05 08:55:58
【问题描述】:

我正在为 SwiftUI 中的项目(新手程序员)做一些工作。

我尝试调整文本框的大小,但 IDK 如何。谁能帮我解决这个问题?

import SwiftUI
struct ContentView: View {
    @Binding var document: NavKov20193123Document
    var body: some View {
        TextEditor(text: $document.text)
            .foregroundColor(.gray)
            .lineSpacing(3)
            .allowsTightening(false)
    }
}
struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView(document: .constant(NavKov20193123Document()))
    }
}

【问题讨论】:

  • 使用.frame(...)修饰符

标签: swift swiftui


【解决方案1】:

你可以使用.frame(width: , height: )

struct ContentView: View {
  var body: some View {
    return Text("Hello world")
      .font(.system(size: 50, weight: .bold))
      .minimumScaleFactor(0.5)
      .frame(width: 100, height: 100)
      .background(Color.yellow)
  }
}

【讨论】:

    猜你喜欢
    • 2020-06-17
    • 2017-01-05
    • 1970-01-01
    • 1970-01-01
    • 2015-09-27
    • 2023-03-31
    • 2019-02-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多