tags:

views:

731

answers:

2

Hi, I have a question, I've design an app with UIButtons and below of it is an UIImageView. My problem was when I start my app the UIButtons get underneath on UIImageView. Here's my code for my UIButtons.

Code:

CALayer *touchedLayer = [myUIButton layer];
CABasicAnimation *wiggleAnimation = [CABasicAnimation animationWithKeyPath:@"transform"];

wiggleAnimation.duration = .1;
wiggleAnimation.repeatCount = 1e100f;
wiggleAnimation.autoreverses = YES;

wiggleAnimation.fromValue = [NSValue valueWithCATransform3D:CATransform3DRotate(touchedLayer.transform, -.15 , 0.0 , -1.0 ,-1.5)];
wiggleAnimation.toValue = [NSValue valueWithCATransform3D:CATransform3DRotate(touchedLayer.transform, -.15 , 0.0 , -1.0 ,-1.5)];

[touchedLayer addAnimation:wiggleAnimation forKey:@"wiggle"];

When the animation start my UIButtons gets underneath, and my UIImageView goes above the UIButtons, why?

A: 

The views will stay in the same Z-order during animation. I assume (because you didn't include that part of the code) that you've added the UIButtonView and UIImageView so that they are not overlapping and of course z-order only becomes apparent when objects overlap. The z-order is determined by the order in which you add sub-views to their parent view.

To make the UIButtonViews appear on top of the UIImageView, add them last. You can also change the order with methods like [sendSubviewToBack] and [bringSubviewToFront].

U62
A: 

Here what happen, I've design it in IB first I put the UIImageView, then the four UIButtons. The UIImageView just serve as background for my four UIButtons. When the applications start everything show correctly, but when I click the icon to execute the code, the problem starts.

This is what I've observed, the four UIButtons, looks like flickering and still it can accept clicked events. My conclusion here is that the UIButtons is still above the UIImageView, but there is a problem displaying them.

What could be the cause of that, Can you suggest something that I can still do my objective.

Thanks

edie