是否有一个九补丁装载机的iPhone? [英] Is there a nine-patch loader for iPhone?

查看:124
本文介绍了是否有一个九补丁装载机的iPhone?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Android有定义叫做九补丁拉伸图像的一个很好的方式。请参见这些文档为理念的描述。我们的想法是围绕一个PNG图像与1像素的边框,您可以定义可拉伸区域和图像填充尺寸。这绝对是辉煌的,我想用这个念头在我的iPhone应用程序。在写我自己的九补丁的UIImage装载机我想我会看看是否已经存在。谷歌不会返回任何结果,所以我没有太多的希望,但它不会伤害问,对不对? : - )

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-pixel border where you can define the stretchable areas and the padding dimensions of the image. This is absolutely brilliant and I'd like to use the idea in my iPhone app. Before writing my own nine-patch to UIImage loader I thought I'd see if one already exists. Google doesn't return any results so I don't have much hope, but it doesn't hurt to ask, right? :-)

编辑:伙计们,我AP preciate的答案,但我知道关于 stretchableImageWithLeftCapWidth ... 。我在寻找code,需要一个路径 @foo.9.png并返回一个可拉伸的UIImage 。这code无疑会使用 stretchableImageWithLeftCapWidth ... 内部。我敢肯定,我可以写使用该方法的code自己。但我要问,如果别人已经做到了。

Folks, I appreciate the answers but I know about stretchableImageWithLeftCapWidth.... I'm looking for code that takes a path @"foo.9.png" and returns a stretchable UIImage. This code will undoubtedly use stretchableImageWithLeftCapWidth... internally. I'm sure I could write the code myself using that method. But I'm asking if somebody else has already done it.

推荐答案

我收到一封电子邮件从Tortuga22软件谁告诉我,他们已经创造了这样一个库,并在Apache许可证下发布了它:

I received an e-mail from Tortuga22 software who informed me that they have created such a library and released it under the Apache license:

公告:<一href="http://blog.tortuga22.com/2010/05/31/announcing-tortuga-22-ninepatch/">http://blog.tortuga22.com/2010/05/31/announcing-tortuga-22-ninepatch/

来源$ C ​​$ C:<一href="http://github.com/tortuga22/Tortuga22-NinePatch">http://github.com/tortuga22/Tortuga22-NinePatch

Source code: http://github.com/tortuga22/Tortuga22-NinePatch

实例:

// loads-and-caches ninepatch and rendered image of requested size
UIImage buttonImg = [TUNinePatchCache imageOfSize:buttonSize 
                                forNinePatchNamed:@"buttonNormalBackground"];
[self.buttonNeedingBackground setImage:buttonImg
                       forControlState:UIControlStateNormal];

这篇关于是否有一个九补丁装载机的iPhone?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆