Set the font in the updateUIView method

This commit is contained in:
Angelo Stavrow 2022-12-12 07:40:41 -05:00
parent 6e60e0ded5
commit 7703e925b7
No known key found for this signature in database
GPG Key ID: 1A49C7064E060EEE

View File

@ -17,17 +17,12 @@ private struct UITextViewWrapper: UIViewRepresentable {
textField.delegate = context.coordinator textField.delegate = context.coordinator
textField.isEditable = true textField.isEditable = true
textField.font = UIFont.preferredFont(forTextStyle: .body)
textField.isSelectable = true textField.isSelectable = true
textField.isUserInteractionEnabled = true textField.isUserInteractionEnabled = true
textField.isScrollEnabled = false textField.isScrollEnabled = false
textField.backgroundColor = UIColor.clear textField.backgroundColor = UIColor.clear
textField.smartDashesType = .no textField.smartDashesType = .no
let font = textStyle
let fontMetrics = UIFontMetrics(forTextStyle: .largeTitle)
textField.font = fontMetrics.scaledFont(for: font)
if nil != onDone { if nil != onDone {
textField.returnKeyType = .next textField.returnKeyType = .next
} }
@ -41,6 +36,10 @@ private struct UITextViewWrapper: UIViewRepresentable {
uiView.text = self.text uiView.text = self.text
} }
let font = textStyle
let fontMetrics = UIFontMetrics(forTextStyle: .largeTitle)
uiView.font = fontMetrics.scaledFont(for: font)
if uiView.window != nil && isEditing { if uiView.window != nil && isEditing {
DispatchQueue.main.async { DispatchQueue.main.async {
uiView.becomeFirstResponder() uiView.becomeFirstResponder()