Fix an issue causing incorrect line wraps in media editor's text overlays.
When calculating layout size of the photo overlay text max width is capped at how wide UITextView was during editing, with the purpose of preserving wrapping between editor (UITextView) and overlay (CATextLayer). Previously though, UITextView was set to auto-shrink its width to content size, which caused max width to not be not enough after changing the font to a bolder variant. The fix is to pin UITextView's width to view margins so that all available width is always used when measuring text overlay height.
This commit is contained in:
parent
f8f17e0770
commit
b5ee24febe
@ -799,12 +799,7 @@ class ImageEditorCanvasView: AttachmentPrepContentView {
|
||||
// * Model transform (so that text doesn't become blurry as you zoom the content).
|
||||
layer.contentsScale = UIScreen.main.scale * item.scaling * transform.scaling
|
||||
|
||||
// TODO: Min with measured width.
|
||||
let maxWidth = imageFrame.size.width * item.unitWidth
|
||||
|
||||
let maxSize = CGSize(width: maxWidth, height: CGFloat.greatestFiniteMagnitude)
|
||||
// TODO: Is there a more accurate way to measure text in a CATextLayer?
|
||||
// CoreText?
|
||||
let maxSize = CGSize(width: imageFrame.size.width * item.unitWidth, height: CGFloat.greatestFiniteMagnitude)
|
||||
let textBounds = attributedString.boundingRect(with: maxSize,
|
||||
options: [ .usesLineFragmentOrigin, .usesFontLeading ],
|
||||
context: nil)
|
||||
|
||||
@ -52,8 +52,8 @@ extension ImageEditorViewController {
|
||||
textContainerBackground.autoPinEdge(toSuperviewEdge: .bottom, withInset: -300)
|
||||
|
||||
textViewContainer.addSubview(textView)
|
||||
textView.autoCenterInSuperview()
|
||||
textView.autoPinWidthToSuperviewMargins(relation: .lessThanOrEqual)
|
||||
textView.autoVCenterInSuperview()
|
||||
textView.autoPinWidthToSuperviewMargins()
|
||||
textView.autoPinHeightToSuperviewMargins(relation: .lessThanOrEqual)
|
||||
textView.widthAnchor.constraint(greaterThanOrEqualToConstant: 40).isActive = true
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user