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;

Comments

Popular posts from this blog

Scroll UITextField above Keyboard in a UITableView OR UIScrollView in Swift and Objective C

Reverting all Xcode settings to default settings

CGRectIntegral