diff --git a/MVMCoreUI/Atoms/Views/Label.swift b/MVMCoreUI/Atoms/Views/Label.swift index a0733521..69e22119 100644 --- a/MVMCoreUI/Atoms/Views/Label.swift +++ b/MVMCoreUI/Atoms/Views/Label.swift @@ -340,6 +340,28 @@ public typealias ActionBlock = () -> Void standardFontSize = 0 } } + + /** + 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) { + + guard let attributedText = self.attributedText else { return } + + let fullString = NSMutableAttributedString(attributedString: attributedText) + + let imageAttachment = NSTextAttachment() + imageAttachment.image = MVMCoreUIUtility.imageNamed("externalLink") + imageAttachment.bounds = CGRect(x: 0, y: 0, width: magnitude, height: magnitude) + + fullString.append(NSAttributedString(string: " ")) + fullString.append(NSAttributedString(attachment: imageAttachment)) + self.attributedText = fullString + } } // MARK: - Atomization diff --git a/MVMCoreUI/SupportingFiles/Media.xcassets/Contents.json b/MVMCoreUI/SupportingFiles/Media.xcassets/Contents.json new file mode 100644 index 00000000..da4a164c --- /dev/null +++ b/MVMCoreUI/SupportingFiles/Media.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/MVMCoreUI/SupportingFiles/Media.xcassets/externalLink.imageset/Contents.json b/MVMCoreUI/SupportingFiles/Media.xcassets/externalLink.imageset/Contents.json new file mode 100644 index 00000000..07a5a9f8 --- /dev/null +++ b/MVMCoreUI/SupportingFiles/Media.xcassets/externalLink.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "exportBlack.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "exportBlack@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "exportBlack@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/MVMCoreUI/SupportingFiles/Media.xcassets/externalLink.imageset/exportBlack.png b/MVMCoreUI/SupportingFiles/Media.xcassets/externalLink.imageset/exportBlack.png new file mode 100644 index 00000000..34f6d7e9 Binary files /dev/null and b/MVMCoreUI/SupportingFiles/Media.xcassets/externalLink.imageset/exportBlack.png differ diff --git a/MVMCoreUI/SupportingFiles/Media.xcassets/externalLink.imageset/exportBlack@2x.png b/MVMCoreUI/SupportingFiles/Media.xcassets/externalLink.imageset/exportBlack@2x.png new file mode 100644 index 00000000..c6de73e8 Binary files /dev/null and b/MVMCoreUI/SupportingFiles/Media.xcassets/externalLink.imageset/exportBlack@2x.png differ diff --git a/MVMCoreUI/SupportingFiles/Media.xcassets/externalLink.imageset/exportBlack@3x.png b/MVMCoreUI/SupportingFiles/Media.xcassets/externalLink.imageset/exportBlack@3x.png new file mode 100644 index 00000000..15f13e32 Binary files /dev/null and b/MVMCoreUI/SupportingFiles/Media.xcassets/externalLink.imageset/exportBlack@3x.png differ