###图片拉伸 ####1.第一种图形界面 ######第三步 图形设置只需要点点就行,至于拉伸大小,系统已替你算好 ####2.代码方式
- 第一种
UIImageView *imageView=[[UIImageView alloc]init]; UIImage *image=[UIImage imageNamed:@"chat_send_nor"]; image=[image resizableImageWithCapInsets:UIEdgeInsetsMake(30, 30, 30, 30) resizingMode:UIImageResizingModeTile]; imageView.image=image; imageView.frame=CGRectMake(30, 50, 200, 200); [self.view addSubview:imageView];
- 第二种
UIImageView *imageView=[[UIImageView alloc]init];UIImage *image=[UIImage imageNamed:@"chat_send_nor"];
// image=[image resizableImageWithCapInsets:UIEdgeInsetsMake(30, 30, 30, 30) resizingMode:UIImageResizingModeTile]; image=[image stretchableImageWithLeftCapWidth:image.size.width*0.5 topCapHeight:image.size.height]; imageView.image=image; imageView.frame=CGRectMake(30, 50, 200, 200); [self.view addSubview:imageView];
// - (UIImage *)stretchableImageWithLeftCapWidth:(NSInteger)leftCapWidth topCapHeight:(NSInteger)topCapHeight __TVOS_PROHIBITED;// @property(nonatomic,readonly) NSInteger leftCapWidth __TVOS_PROHIBITED; // default is 0. if non-zero, horiz. stretchable. right cap is calculated as width - leftCapWidth - 1// @property(nonatomic,readonly) NSInteger topCapHeight __TVOS_PROHIBITED; // default is 0. if non-zero, vert. stretchable. bottom cap is calculated as height - topCapWidth - 1////实际就是1,也是图形与图形界面一样的结果// right = width - left - 1;// 1 = width - left - right;// bottom = height - top - 1;// 1 = height - top - bottom;//可以将其封装成一个uiimage的分类,这样可以重用```
####3.github地址