效果图:
参考代码:
UILabel *contentLabel = [[UILabel alloc]init];
contentLabel.textColor = [UIColor whiteColor];
contentLabel.backgroundColor = [UIColor clearColor];
//contentLabel.textAlignment = NSTextAlignmentCenter;//设置内容对齐
contentLabel.font = [UIFont boldSystemFontOfSize:13.0];
contentLabel.text = @"123456789";
CGSize size = [contentLabel.text sizeWithFont:contentLabel.font constrainedToSize:CGSizeMake(80, 100) lineBreakMode:NSLineBreakByWordWrapping];
UIImage* image = [UIImage imageNamed:@"Point.png"];
//选取图片的某一像素进行放大做文字背景
image = [image stretchableImageWithLeftCapWidth:20 topCapHeight:15];
contentLabel.frame = CGRectMake(15, 4, size.width, size.height);
UIImageView* updateImage = [[UIImageView alloc]initWithFrame:CGRectMake(320-30-size.width, 150, 30+size.width ,10+size.height )];
updateImage.image = image;
[updateImage addSubview:contentLabel];
[self.view addSubview:updateImage];
附加上那个图片资源:point.png
版权属于:东哥笔记 - DongGe.org
本文链接:https://dongge.org/blog/25.html
自2017年12月26日起,『转载以及大段采集进行后续编辑』须注明本文标题和链接!否则禁止所有转载和采集行为!