I need to embed small icons ( sort of custom bullets ) to my UILabel
in iOS7.
How can I do this in interface designer? Or at least in code?
In Android there are leftDrawable
and rightDrawable
for labels, but how it is done in iOS?
Sample in android :
Your reference image looks like a button. Try (can also be done in Interface Builder):
Swift 4
UIlabel
Extension to add Image to Label with reference to above answersSwift 2.0 version:
Try dragging a
UIView
onto the screen in IB. From there you can drag aUIImageView
andUILabel
into the view you just created. Set the image of theUIImageView
in the properties inspector as the custom bullet image (which you will have to add to your project by dragging it into the navigation pane) and you can write some text in the label.You can do this with iOS 7's text attachments, which are part of TextKit. Some sample code:
Here is the way to embed icon in UILabel.
Also to Align the Icon use attachment.bounds
Swift 4.2
Objective-C Version