[英]TextEditor added / SwiftUi
I could not adjust the appearance of the Text Editor I created.text will have margins.我无法调整我创建的文本编辑器的外观。文本将有边距。 I tried to do it myself but I messed it up, I couldn't.I want it to be like the picture.
我试着自己做,但我搞砸了,我做不到。我希望它像图片一样。
VStack {
TextEditor(text: $inputText)
.background(Color.black)
.frame(height:geometry.size.height / 3, alignment: .center)
.cornerRadius(25)
.border(Color.yellow, width: 5)
.lineSpacing(10)
.autocapitalization(.words)
.disableAutocorrection(true)
.padding()
}
Spacer().frame(height: geometry.size.height / 15)
VStack {
Button(action: {}, label: {
Text("Gönder")
.frame(width: geometry.size.width / 3, height: 50)
.padding(10)
.font(Font.system(size: 30, weight: .medium, design: .serif))
.foregroundColor(.white)
.background(RoundedRectangle(cornerRadius: 30))
.foregroundColor(.init(red: 45 / 255, green: 0 / 255, blue: 112 / 255))
})
}
First, for changing TextEditor
background color I could not find a SwiftUI
100% solution for that (maybe apple will support this in future ), so you need to change every UITextView.appearance().backgroundColor
in the app首先,为了更改
TextEditor
背景颜色,我找不到SwiftUI
100% 解决方案(也许苹果将来会支持这个),所以你需要更改应用程序中的每个UITextView.appearance().backgroundColor
init() {
UITextView.appearance().backgroundColor = UIColor.black
}
don't miss import UIKit
不要错过
import UIKit
Then for corner radius, you need to use overlay
modifier for a rounded corners然后对于圆角半径,您需要对圆角使用
overlay
修改器
VStack {
TextEditor(text: $inputText)
.frame(height:geometry.size.height / 3, alignment: .center)
.lineSpacing(10)
.autocapitalization(.words)
.disableAutocorrection(true)
.padding()
}.overlay(
RoundedRectangle(cornerRadius: 25)
.stroke(Color.yellow, lineWidth: 5)
)
.padding()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.