iOS图片拉伸三种方式

###图片拉伸 ####1.第一种图形界面 第一步 第二步 ######第三步 图形设置只须要点点就行,至于拉伸大小,系统已替你算好 ####2.代码方式git

  • 第一种
    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];github

//    - (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地址 githubui

相关文章
相关标签/搜索