TextEditor added / SwiftUi

Viewed 2442

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.

enter image description here

  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))

                })
            }
1 Answers

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

init() {
    UITextView.appearance().backgroundColor = UIColor.black
}

don't miss import UIKit

Then for corner radius , you need to use overlay modifier for a rounded corners

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() 
Related