Posts

Showing posts with the label NSAttributedString

Add shadow to text in UITextView

Image
    NSShadow * shadow = [[NSShadow alloc] init];     shadow.shadowColor = [UIColor blackColor];     shadow.shadowOffset = CGSizeMake(1, 2);        NSDictionary * textAttributes =  @{                                        NSForegroundColorAttributeName : [UIColor blueColor],                                        NSShadowAttributeName          : shadow,                       ...

add small image after text in UILabel

NSTextAttachment * attachment = [[ NSTextAttachment alloc ] init ]; attachment . image = [ UIImage imageNamed :@ "myimage.png" ]; NSAttributedString * attachmentString = [ NSAttributedString attributedStringWithAttachment : attachment ]; NSMutableAttributedString * myString = [[ NSMutableAttributedString alloc ] initWithString :@ "My label text" ]; [ myString appendAttributedString : attachmentString ]; myLabel . attributedText = myString ;