From 8bf4befd02710466970bef8a1377de33bce17dd1 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Mon, 1 Jul 2019 14:23:44 -0400 Subject: [PATCH] link icon now scales in size with the text. --- MVMCoreUI/Atoms/Views/Label.swift | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/Label.swift b/MVMCoreUI/Atoms/Views/Label.swift index a524dbac..858e87d6 100644 --- a/MVMCoreUI/Atoms/Views/Label.swift +++ b/MVMCoreUI/Atoms/Views/Label.swift @@ -342,14 +342,11 @@ public typealias ActionBlock = () -> Void } } - /** - Appends an external link imcage to the end of the attributed string. - - - Attention: This method expects text to be set first. Otherwise, it will do nothing. - - Parameters: - - magnitude: Applied to Width and Height of image for congruency. - */ - public func addExternalLinkIcon(magnitude: Int = 12) { + + ///Appends an external link image to the end of the attributed string. + public func addExternalLinkIcon() { + + let size = round(font.pointSize * 0.8) guard let attributedText = self.attributedText else { return } @@ -357,7 +354,7 @@ public typealias ActionBlock = () -> Void let imageAttachment = NSTextAttachment() 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(attachment: imageAttachment))