How to embed small icon in UILabel

2019-01-03 11:53发布

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 :

android sample

15条回答
爷、活的狠高调
2楼-- · 2019-01-03 12:30

You could use a UITextField with the leftView property and then set the enabled property to NO

Or use a UIButton and setImage:forControlState

查看更多
该账号已被封号
3楼-- · 2019-01-03 12:34

you have to make a custom object where you used a UIView and inside you put a UIImageView and a UILabel

查看更多
爷、活的狠高调
4楼-- · 2019-01-03 12:39

try this way...

  self.lbl.text=@"Drawble Left";
    UIImageView *img=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 20, 20)];
    img.image=[UIImage imageNamed:@"Star.png"];
    [self.lbl addSubview:img];
查看更多
登录 后发表回答