Is there a nine-patch loader for iPhone?

后端 未结 4 1913
小蘑菇
小蘑菇 2020-12-22 22:19

Android has a nice way of defining stretchable images called a nine-patch. See these docs for a description of the concept. The idea is to surround a png image with a 1-pi

4条回答
  •  生来不讨喜
    2020-12-22 22:49

    Yes UIImage does support something like it. See

    - (UIImage *)stretchableImageWithLeftCapWidth:(NSInteger)leftCapWidth topCapHeight:(NSInteger)topCapHeight and the documentation for leftCapWidth and topCapHeight

    basically the image is not stretched in the area leftCapWidth pixels from the left and right edge and topCapHeight pixels from the top and the bottom. When the image is scaled the area inside of these limits is subject to stretching.

提交回复
热议问题