图片拉伸:
- (UIImage *)stretchableImageWithLeftCapWidth:(NSInteger)leftCapWidth topCapHeight:(NSInteger)topCapHeight;
以某个点拉伸图片,主要也就是拉伸纯色背景图
具体用法:
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.view.backgroundColor = [UIColor brownColor];
UIImage * image = [UIImage imageNamed:@"bg.png"];
UIImage * stretchImage = [image stretchableImageWithLeftCapWidth:30 topCapHeight:20];
UIImageView * imageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 74, 300, 49)];
imageView.image = stretchImage;
[self.view addSubview:imageView];
UIImageView * imageView1 = [[UIImageView alloc] initWithFrame:CGRectMake(10, 174, 300, 49)];
imageView1.image = image;
imageView1.contentMode = UIViewContentModeScaleAspectFit;
imageView1.backgroundColor = [UIColor purpleColor];
[self.view addSubview:imageView1];
}