0

I need to create table cells with a very complicated background image for each: http://i.stack.imgur.com/PBL0S.png

There is a transparent circle in the center of it. And height of my cell depends from its content - it may vary. But I need this circle to always be in the center of background image and have a constant size.

My solution is: cut the image along for 2 parts and then, using the method resizableImageWithCapInsets: create two UIImageView's and locate them one below the other. There is the problem: this method is only availible since iOS 5, but my app needs to run under iOS 4.3. Unfortunatelly, I can't use method stretchableImageWithLeftCapWidth:topCapHeight: because top and bottom caps on my half-images obtained with different heights.

Please, help me to create the method with the same functionality resizableImageWithCapInsets: Or, if there is any better solution, tell it to me, please.

4

1 回答 1

2

直接的方法可以涉及三个图像视图:

  • top imageview:带有标签图像顶部的可拉伸图像
  • center imageview:不可拉伸的固定尺寸图像,标签图像的中心部分包​​括白洞
  • 底部图像视图:带有标签图像底部的可拉伸图像

子类化UITableViewCell并覆盖layoutSubviews,以使顶部图像视图始终具有相同的大小,而中心图像视图保留其大小和中心位置。

编辑:

您还可以stretchableImageWithLeftCapWidth:topCapHeight:对不同的图像使用不同帽高的方法。我看不出你的方法不应该奏效的原因。

于 2013-05-27T14:17:15.580 回答