stretchableImageWithLeftCapWidth:leftCapWidth topCapHeight:

来源:互联网 发布:parsley.js 表单验证 编辑:程序博客网 时间:2024/05/21 14:09

图片拉伸:

- (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];        }


0 0
原创粉丝点击