你的位置:首页 > 操作系统

[操作系统]【代码笔记】使图片两边不拉伸,中间拉伸


代码:

复制代码
- (void)viewDidLoad{  [super viewDidLoad];  // Do any additional setup after loading the view.    //使图片两边不拉伸,中间拉伸  UIImage *image = [UIImage imageNamed:@"1.jpg"];  image = [image stretchableImageWithLeftCapWidth:floorf(image.size.width/2) topCapHeight:floorf(image.size.height/2)];    UIImageView *imageView=[[UIImageView alloc]initWithFrame:CGRectMake(50, 100, 200, 200)];  imageView.backgroundColor=[UIColor redColor];  imageView.image=image;  [self.view addSubview:imageView];}
复制代码