link icon now scales in size with the text.

This commit is contained in:
Kevin G Christiano 2019-07-01 14:23:44 -04:00
parent ce681db033
commit 8bf4befd02

View File

@ -342,14 +342,11 @@ public typealias ActionBlock = () -> Void
} }
} }
/**
Appends an external link imcage to the end of the attributed string. ///Appends an external link image to the end of the attributed string.
public func addExternalLinkIcon() {
- Attention: This method expects text to be set first. Otherwise, it will do nothing.
- Parameters: let size = round(font.pointSize * 0.8)
- magnitude: Applied to Width and Height of image for congruency.
*/
public func addExternalLinkIcon(magnitude: Int = 12) {
guard let attributedText = self.attributedText else { return } guard let attributedText = self.attributedText else { return }
@ -357,7 +354,7 @@ public typealias ActionBlock = () -> Void
let imageAttachment = NSTextAttachment() let imageAttachment = NSTextAttachment()
imageAttachment.image = MVMCoreUIUtility.imageNamed("externalLink") imageAttachment.image = MVMCoreUIUtility.imageNamed("externalLink")
imageAttachment.bounds = CGRect(x: 0, y: 0, width: magnitude, height: magnitude) imageAttachment.bounds = CGRect(x: 0, y: 0, width: size, height: size)
fullString.append(NSAttributedString(string: " ")) fullString.append(NSAttributedString(string: " "))
fullString.append(NSAttributedString(attachment: imageAttachment)) fullString.append(NSAttributedString(attachment: imageAttachment))