iPhone stretchchableImageWithLeftCapWidth仅产生“D” [英] iPhone stretchableImageWithLeftCapWidth only makes "D"s

查看:147
本文介绍了iPhone stretchchableImageWithLeftCapWidth仅产生“D”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

UIImage *aImage = [[UIImage imageNamed:@"Gray_Button.png"] stretchableImageWithLeftCapWidth:25 topCapHeight:0];

尝试制作玻璃药丸按钮。

Trying to make a "glass pill button".

如果图像更大,拉伸会做什么......我试图在...上使用的按钮更小?

What does "stretch" do if the image is bigger... and the button I'm trying to use it on... is smaller?

图像拉伸和收缩吗?

我问的原因是因为我的所有图像看起来都像D形。

The reason I ask... is because all my images end up look like a "D" shape.

左边是方形的...而右边是圆形的。

The left side is squared-off... and the right side is rounded.

什么是D-形状告诉你我做错了?
太多......或者太少......leftCap设置?
图像太大?

What would a D-shape tell you that I'm doing wrong? Too much.. or too little... "leftCap setting"? Too large an image?

推荐答案

如果两者都 leftCapWidth 和 topCapHeight 非零。

     leftCapWidth
      <----->
      +--------------+ ^
      |     | |      | |
      |  A  | |  B   | | topCapHeight
      |-----+·+------| v
      |-----+·+------|
      |  C  | |  D   |
      |     | |      |
      +--------------+

中心部分的大小总是1像素,这是拉伸的部分,例如:

The central parts are always 1 px in size, and this is the part that is stretched, for example:

     leftCapWidth (constant!)
      <----->
      +------------------+ ^
      |     |     |      | |
      |  A  |     |  B   | | topCapHeight (constant!)
    v |-----+ - - +------| v
    | |     .     .      |
    | |     .     .      |
    ^ |-----+ - - +------|
      |  C  |     |  D   |
      |     |     |      |
      +------------------+
            >-----<
        stretched region

要创建玻璃药丸按钮,您应该填充圆形边框进入上面的区域A,B,C和D,并将该药丸的半径提供给 leftCapWidth topCapHeight

To create a "glass pill button", you should fill the rounded border into the regions A, B, C and D above, and supply the radius of that pill into both the leftCapWidth and topCapHeight.

此外,可拉伸图像不可收缩。如果您尝试使用比您想要应用它的按钮(或其他任何东西)更大的可伸缩图像,它们可能会被错误地渲染(特别是在较旧的iOS上)。

Also, a stretchable image is not shrinkable. If you try to use stretchable images bigger than the buttons (or whatever else) you want to apply it to, they may be rendered incorrectly (especially on older iOSes).

这篇关于iPhone stretchchableImageWithLeftCapWidth仅产生“D”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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