UILabel and NSLinkAttributeName: Link is not clickable

I can answer my own question now: I am using UITextView instead of UILabel now. I have formatted the UITextView to look and behave like my labels and added: UITextView *textView = [[UITextView alloc] init]; textView.scrollEnabled = NO; textView.editable = NO; textView.textContainer.lineFragmentPadding = 0; textView.textContainerInset = UIEdgeInsetsMake(0, 0, 0, 0); textView.delegate = self; Don’t forget … Read more

How to set color of templated image in NSTextAttachment

It seems that there’s a bug in UIKit. There’s a workaround for that ;] For some reason you need to append empty space before image attachment to make it work properly with UIImageRenderingModeAlwaysTemplate. So your snippet would look like that (mine is in ObjC): – (NSAttributedString *)attributedStringWithValue:(NSString *)string image:(UIImage *)image { NSTextAttachment *attachment = [[NSTextAttachment … Read more

Tap on a part of text of UILabel

#swift 4.2 Please find the solution here for getting specific text action of Label. Label declaration @IBOutlet weak var lblTerms: UILabel! Set attributed text to the label let text = “Please agree for Terms & Conditions.” lblTerms.text = text self.lblTerms.textColor = UIColor.white let underlineAttriString = NSMutableAttributedString(string: text) let range1 = (text as NSString).range(of: “Terms & … Read more