英文:
Vertically align Image within TextEditor
问题
I am attempting to have my image and textEditor text to both be centered vertically within the TextEditor (similar to the textField below it. I tried GeometryReader to no avail, along with any alignment trick I could think of.
Any help would be great!
HStack {
Image(systemName: "person.crop.rectangle")
.foregroundColor(Color("ButtonTwo"))
TextEditor(text: $userBio)
.foregroundColor(.gray)
.padding(.leading, 20)
}
英文:
I am attempting to have my image and textEditor text to both be centered vertically within the TextEditor (similar to the textField below it. I tried GeometryReader to no avail, along with any alignment trick I could think of.
Any help would be great!
HStack {
Image(systemName: "person.crop.rectangle")
.foregroundColor(Color("ButtonTwo"))
TextEditor(text: $userBio)
.foregroundColor(.gray)
.padding(.leading, 20)
}
答案1
得分: 1
希望这能给你一些想法。
HStack(spacing: 20) {
Image(systemName: "person.crop.rectangle")
.foregroundColor(.mint)
TextEditor(text: $text)
.foregroundColor(.gray)
.frame(minHeight: 44)
.fixedSize(horizontal: false, vertical: true)
}
.padding()
.border(Color.gray, width: 1)
当在文本编辑器中有多行文本时,会得到以下结果:
英文:
hope this will give you some ideas
HStack(spacing: 20) {
Image(systemName: "person.crop.rectangle")
.foregroundColor(.mint)
TextEditor(text: $text)
.foregroundColor(.gray)
.frame(minHeight: 44)
.fixedSize(horizontal: false, vertical: true)
}
.padding()
.border(Color.gray, width: 1)
this is what you get when having multiple lines in your text editor
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论