I want to include png image in between my text of a label. how to proceed with this in objective-c.
Asked
Active
Viewed 58 times
1
-
1try this one: http://stackoverflow.com/questions/19318421/how-to-embed-small-icon-in-uilabel – sonique May 03 '16 at 06:07
-
1thanx that has solved my problem :-) – raj May 03 '16 at 06:12
1 Answers
1
This is the answer in case someone find it useful----->
NSTextAttachment *attachment = [[NSTextAttachment alloc] init];
attachment.image = [UIImage imageNamed:@"Attach-52.png"];
NSAttributedString *attachmentString = [NSAttributedString attributedStringWithAttachment:attachment];
NSMutableAttributedString *myString= [[NSMutableAttributedString alloc] initWithString:@"My label text"];
[myString appendAttributedString:attachmentString];
myLabel.attributedText = myString;
Likewise you can add png image through NSAttributedString.

raj
- 63
- 5