Skip to content

Instantly share code, notes, and snippets.

@Anatoli-Petrosyants
Created February 1, 2018 07:45
Show Gist options
  • Save Anatoli-Petrosyants/2f9409998938d164b0f5bbae3dc3d639 to your computer and use it in GitHub Desktop.
Save Anatoli-Petrosyants/2f9409998938d164b0f5bbae3dc3d639 to your computer and use it in GitHub Desktop.
extension NSTextAttachment {
func setImageHeight(height: CGFloat) {
guard let image = image else { return }
let ratio = image.size.width / image.size.height
bounds = CGRect(x: bounds.origin.x, y: bounds.origin.y, width: ratio * height, height: height)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment