UILabel How to set background image

来源:互联网 发布:风靡美国华人网络的菜 编辑:程序博客网 时间:2024/05/17 22:37
UILabel *myLabel=[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 20)];UIImage *img = [UIImage imageNamed:@"a.png"];CGSize imgSize = myLabel.frame.size;UIGraphicsBeginImageContext( imgSize );[img drawInRect:CGRectMake(0,0,imgSize.width,imgSize.height)];UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();UIGraphicsEndImageContext();myLabel.backgroundColor = [UIColor colorWithPatternImage:newImage];

0 0
原创粉丝点击