What is use of stretching property of UIImageView. How I can use this property.?

纵饮孤独 提交于 2019-12-07 01:37:02

问题


I want to know how can i use this property for UIImageView.


回答1:


Stretching properties are pretty simple, as stated by Karol Kozub in this article:

The fraction of the original image left without stretching on the left is specified by X

The fraction of the original image that gets stretched in the x-axis is specified by Width

The fraction of the original image left without stretching on the right is equal to 1 – X – Width

If we use 0 for Width the stretched area will interpolate between the last pixel of the left part and the first pixel of the right part

The y-axis works analogously




回答2:


This sets the contentStretch property for views (this is a UIView property, not specifically a UIImageView property). This property has been deprecated since iOS 6, however, so you shouldn't use it.

The replacement, specifically for images, is resizableImageWithCapInsets. The normal use of this is to create an image with a left and right side (or top and bottom), and a single-pixel wide "middle" that is stretched across the view. It's common for custom buttons both because it's flexible to a variety of widths, and because it saves some space.

See "Defining a Stretchable Image" in the UIImage docs for full details.



来源:https://stackoverflow.com/questions/37413585/what-is-use-of-stretching-property-of-uiimageview-how-i-can-use-this-property

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!