给UILabel添加背景图片:
self.accountLabel = [[UILabel
alloc]initWithFrame:CGRectMake(kXW(accountBtn),
kY(accountBtn), 250,
32)];
self.accountLabel.backgroundColor = [UIColor
colorWithPatternImage:[UIImage
imageNamed:@"qipao.png"]];
图片拉伸:
在iOS6.0中,UIImage提供了一个方法处理图片拉伸
-
- (UIImage *)resizableImageWithCapInsets:(UIEdgeInsets)capInsets resizingMode:(UIImageResizingMode)resizingMode
- UIImageResizingModeStretch:拉伸模式,通过拉伸UIEdgeInsets指定的矩形区域来填充图片
- UIImageResizingModeTile:平铺模式,通过重复显示UIEdgeInsets指定的矩形区域来填充图片
-
CGFloat top = 25;
-
CGFloat bottom = 25 ;
-
CGFloat left = 10;
-
CGFloat right = 10;
-
UIEdgeInsets insets = UIEdgeInsetsMake(top, left, bottom, right);
-
-
image = [image resizableImageWithCapInsets:insets resizingMode:UIImageResizingModeStretch];
版权声明:本文为博主原创文章,未经博主允许不得转载。
图片处理
原文:http://blog.csdn.net/tubiebutu/article/details/46818483