ZMiOS
//将图片用瓦片拉伸的方式进行拉伸
- (UIImage *)changeImgWith:(NSString *)imgName
{
    UIImage *img = [UIImage imageNamed:imgName];
    CGFloat W = img.size.width*0.5;
    CGFloat H = img.size.height*0.5;
    return  [img resizableImageWithCapInsets:UIEdgeInsetsMake(W,H,W,H) resizingMode:UIImageResizingModeTile];
    
}

注:在使用此方法以后要相应的把设置此图片的控件的内边距设置好并且在设置frame的时候也要把size的宽(加上内边距的左边和右边的距离)和高(加上内边距的上边和下边的距离)如图:

 

//设置btn的内边距
 Btn.contentEdgeInsets = UIEdgeInsetsMake(30, 30, 30, 30);
//因为内边距增加了所以size也要增加
_BtnF = CGRectMake(textX, textY, textSize.width+60,textSize.height+60);

 

分类:

技术点:

相关文章:

  • 2021-11-18
  • 2021-12-11
  • 2022-12-23
  • 2021-12-05
  • 2021-11-18
  • 2022-01-25
  • 2022-12-23
猜你喜欢
  • 2022-01-03
  • 2021-12-15
  • 2021-11-24
  • 2022-01-30
  • 2022-02-07
  • 2022-01-01
  • 2021-11-30
相关资源
相似解决方案