开发者

Change UI Draw Order on iPhone

I currently have a UI built in Interface Builder-- it is basically consisted of a background image and a few labels. I need to animate some elements (images) underneath the labels but over the background, but I also need to draw them in a specific z-order.

I was looking around and came across CATransformLayer-- I'm still looking into it. Is this the 开发者_运维知识库best way to manage the Z-order of images in order to simulate 3D? I don't want to use Open GL as the animation I am doing will be very simple fake 3D...


Background:

On iPhone, UIViews have a subview NSArray. The root, a UIWindow is drawn first, then its subviews in order, then their subviews. In addition, there is a second hierarchy: each UIView has a CALayer array. The root CALayer draws first, then the each CALayer in order.

Suggestion:

Yes, you can do it as you outlined. However, the code may be a bit simpler if you do the following:

In your specific case, use a UIView to hold the background. Give it two subviews, initially transparent, full-size, with springs and struts set in Interface Builder to keep it the full size of the background. Arrange them in Interface Builder's outline view (-0) so that the UIView ImageViewHolder is listed before the UIView ButtonViewHolder.

That way, you can insert and remove UIImageViews from the ImageViewHolder UIView, and they'll be drawn above the background, and below the UIButtons.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜