Skip to content

Instantly share code, notes, and snippets.

@gmoraleda
Created November 15, 2018 13:03
Show Gist options
  • Save gmoraleda/82674fd1d88d3451240684478bdafe3d to your computer and use it in GitHub Desktop.
Save gmoraleda/82674fd1d88d3451240684478bdafe3d to your computer and use it in GitHub Desktop.
[...]
// Add observer in layoutSubviews()
pictureImageView.observe(\UIImageView.frame, options: [.new]) { [weak self] (_, _) in
self?.updateTextViewFrame()
}
[...]
private func updateTextViewFrame() {
contentView.layoutIfNeeded()
let rect = pictureImageView.convert(pictureImageView.bounds, to: descriptionTextView)
let imagePath = UIBezierPath(rect: rect)
descriptionTextView.textContainer.exclusionPaths = [imagePath]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment