美文网首页
iOS UIImageView拉伸注意点

iOS UIImageView拉伸注意点

作者: samtake | 来源:发表于2019-10-09 02:52 被阅读0次
image.png
  • 先设定图片让UIImageView有个frame
UIImageView *earnPic = [[UIImageView alloc]initWithImage:IMGWithName(@"yujizuangbg")];
  • 然后根据图片的高来拉伸它的宽
CGFloat imgHeight = self.earnPic.frame.size.height;
self.earnPic.frame = CGRectMake(self.title_lab.wgLeft, self.title_lab.wgBottom+12*kFixRax, 112*kFixRaxW, imgHeight);
UIImage *earnNewImage = [self.earnPic.image resizableImageWithCapInsets:UIEdgeInsetsMake(0*kFixRaxW,112*kFixRaxW,imgHeight,0) resizingMode:UIImageResizingModeStretch];
self.earnPic.image=earnNewImage;

反之亦然,具体情况具体分析吧!

相关文章

网友评论

      本文标题:iOS UIImageView拉伸注意点

      本文链接:https://www.haomeiwen.com/subject/eavryctx.html