深入理解iOS API系列(二)UIImage的resizableImageWithCapInsets:resizingMode:
2015-04-12 17:30
302 查看
最近在看《programming iOS8》,看到第二章的“可调整大小的images”。实现这个效果的方法我们并不陌生,可以参看MJ的博客http://blog.csdn.net/q199109106q/article/details/8615661
。当然我们要讨论的不是API的变动,我们更关注UIImageResizingMode的影响。它有两个枚举量UIImageResizingModeTile和 UIImageResizingModeStretch。我觉得作者对于这个变量的效果的描述还是非常到位的。
UIImageResizingModeTile
The interior rectangle of the inset area is tiled (repeated) in the interior; each edgeis formed by tiling the corresponding edge rectangle outside the inset area. The fourcorner rectangles outside
the inset area are drawn unchanged.
UIImageResizingModeStretch
The interior rectangle of the inset area is stretchedonceto
fill the interior; each edgeis formed by stretching the corresponding edge rectangle outside the inset areaonce.
The four corner rectangles outside the inset area are drawn unchanged.
对于Tile方式的,我们可以把一张图分解为3部分,一个是inset确定的内部区域,一个是四个端帽,还有一个是剩余部分,剩余部分刚好是与inset的四条边毗邻的四个矩形。Tile后的效果你可以认为是拼积木,先inset平铺若干个,然后放上4个端帽,最后平铺剩余部分。类似地,对于Stretch方式的,只要将前者中的“平铺”改成“拉伸”就行了。顺便说下,常用的拉伸策略是把几乎是原始图片的一半作为capinset,仅仅在中间留出1到2像素来填充整个内部。
现在再来看看http://www.cnblogs.com/heyonggang/archive/2013/12/19/3482733.html,你应该能够理解作者的意思了。其他的博文:
http://www.cnblogs.com/zhangqifeng/p/4004433.html http://blog.sina.com.cn/s/blog_884e78b2010150b3.html http://duchengjiu.iteye.com/blog/1901288
严重参考:
http://www.th7.cn/Program/IOS/201405/203735.shtml
。当然我们要讨论的不是API的变动,我们更关注UIImageResizingMode的影响。它有两个枚举量UIImageResizingModeTile和 UIImageResizingModeStretch。我觉得作者对于这个变量的效果的描述还是非常到位的。
UIImageResizingModeTile
The interior rectangle of the inset area is tiled (repeated) in the interior; each edgeis formed by tiling the corresponding edge rectangle outside the inset area. The fourcorner rectangles outside
the inset area are drawn unchanged.
UIImageResizingModeStretch
The interior rectangle of the inset area is stretchedonceto
fill the interior; each edgeis formed by stretching the corresponding edge rectangle outside the inset areaonce.
The four corner rectangles outside the inset area are drawn unchanged.
对于Tile方式的,我们可以把一张图分解为3部分,一个是inset确定的内部区域,一个是四个端帽,还有一个是剩余部分,剩余部分刚好是与inset的四条边毗邻的四个矩形。Tile后的效果你可以认为是拼积木,先inset平铺若干个,然后放上4个端帽,最后平铺剩余部分。类似地,对于Stretch方式的,只要将前者中的“平铺”改成“拉伸”就行了。顺便说下,常用的拉伸策略是把几乎是原始图片的一半作为capinset,仅仅在中间留出1到2像素来填充整个内部。
现在再来看看http://www.cnblogs.com/heyonggang/archive/2013/12/19/3482733.html,你应该能够理解作者的意思了。其他的博文:
http://www.cnblogs.com/zhangqifeng/p/4004433.html http://blog.sina.com.cn/s/blog_884e78b2010150b3.html http://duchengjiu.iteye.com/blog/1901288
严重参考:
http://www.th7.cn/Program/IOS/201405/203735.shtml
相关文章推荐
- UIImage - resizableImageWithCapInsets & - resizableImageWithCapInsets:resizingMode
- iOS聊天气泡的处理——图片拉伸resizableImageWithCapInsets:resizingMode
- resizableImageWithCapInsets:resizingMode 图片拉伸 使用方法
- 理解UIImage 拉伸图片 resizableImageWithCapInsets
- 深入理解iOS API系列(三)UiView事件传递相关函数:pointInside:withEvent:和hittest:withevent:
- iOS UIImage 使用resizableImageWithCapInsets 适配UIImageView
- resizableImageWithCapInsets: resizingMode:拉伸图片
- ios UIImage图片拉伸 resizableImageWithCapInsets:
- IOS UIImage图片拉伸技巧-resizableImageWithCapInsets
- [UIImage resizableImageWithCapInsets:] 函数说明
- 深入理解iOS API系列(四)理解CNContactPickerDelegate
- iOS图片拉伸技巧—— resizableImageWithCapInsets
- ios开发 - iPhone图片拉伸:resizableImageWithCapInsets
- [UIImage resizableImageWithCapInsets:]使用注意
- resizableImageWithCapInsets认知和对@2x图片的理解
- [UIImage resizableImageWithCapInsets:]使用注意
- [UIImage resizableImageWithCapInsets:]使用注意
- iOS编程——Swift使用resizableImageWithCapInsets来拉伸图片
- iOS图片拉伸技巧—— resizableImageWithCapInsets
- IOS resizableImageWithCapInsets 拉伸图片时出现变形不成功