Ах, я понял это. UITextView
, который у меня есть, находится в UIViewController
(для лучшего контроля размера)
Серый sh фон не отображается с этой настройкой.
public class CustomTextView: UIViewController {
var textView: UITextView!
init() {
super.init(nibName: nil, bundle: nil)
self.textView = UITextView(frame: .zero)
self.textView.frame = self.view.bounds
self.view.addSubview(textView)
}
required init?(coder: NSCoder) {
super.init(coder: coder)
textView = UITextView(frame: .zero)
textView.frame = self.view.bounds
self.view.addSubview(textView)
}
}
Тогда в вашем UIViewRepresentable
public func makeUIViewController(context: UIViewControllerRepresentableContext<TextViewController_UI>) -> TextViewController_UI.CustomTextView {
let textViewCont = CustomTextView()
textViewCont.textView.font = UIFont.preferredFont(forTextStyle: UIFont.TextStyle.body)
textViewCont.textView.text = "placeholder"
textViewCont.textView.textColor = .placeholderText
textViewCont.textView.backgroundColor = .systemBackground
textViewCont.textView.layer.borderColor = UIColor.placeholderText.cgColor
textViewCont.textView.layer.borderWidth = 1
textViewCont.textView.layer.cornerRadius = 6
return textViewCont
}