Burf2000
Burf2000

Reputation: 5193

iPhone : Layer.zPosition issue

Hope someone can help me out here.

I have a viewcontroller with view that contains a red image. This image has a zPosition of 1.

There a function I press and it adds a new view on top of this (and viewcontroller). that places a button on top of the red bar with a zPosition of 2.

Then when you press the button, a 3rd view (and controller) slides up a menu behind both of them (image and button) as it has a zPosition of 0.

Now the issue is that the menu slides up under the red bar as expected however for some unknown reason (why I am here) the button seems to be under the red image. What every I try, I cant get the button to sit on top of the image.

I have tried:

propertyViewController.shortlistButton.layer.zPosition = 2;

[propertyViewController.view bringSubviewToFront:propertyViewController.shortlistButton];

propertyViewController.shortlistButton.layer.transform = CATransform3DMakeTranslation(1, 1, 1);

(stackoverflow post)

Upvotes: 1

Views: 1170

Answers (1)

Bartosz Ciechanowski
Bartosz Ciechanowski

Reputation: 10333

You could simply try adding the red button as a subview of red image.

Upvotes: 4

Related Questions