nsattributedstring
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 resize an image or done as a NSAttributedString NSTextAttachment (or set its initital size)
You should set bounds form attachment to resize image like this: attachment.bounds = CGRectMake(0, 0, yourImgWidth, yourImgHeight)
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
Wrapping Text in a UITextView Around a UIImage WITHOUT CoreText
This seems to do the trick: UIBezierPath * imgRect = [UIBezierPath bezierPathWithRect:CGRectMake(0, 0, 100, 100)]; self.textView.textContainer.exclusionPaths = @[imgRect]; Works only from iOS 7 and up.
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