infinitered / redpotion

We believe iPhone development should be clean, scalable, and fast with a language that developers not only enjoy, but actively choose. With the advent of Ruby for iPhone development the RubyMotion community has combined and tested the most active and powerful gems into a single package called RedPotion
MIT License
233 stars 40 forks source link

Setting the on screen order (z-index) of views #160

Closed andersennl closed 8 years ago

andersennl commented 8 years ago

Hi, I couldn't find a working solution to set the order of for example two overlapping images. Lets say I have a big and a small image. How can I prevent the small one from being covered by the big one?

What I've found was st.order and st.z_position which both didn't seem to have an effect. If I'm not mistaken, the docs only seem to touch this topic very briefly, maybe you can help me directly? Thanks!

squidpunch commented 8 years ago

By default the last appended view will be the top view, so if you put the larger image on the view before the smaller, then it should just work without any special styling.

Otherwise you should be able to set the zPosition of the layer by setting the z_position as you mentioned, have a repo with the issue repeatable?

andersennl commented 8 years ago

Ah I totally forgot to mention that, in this case, the order in which I append the two images strangely doesn't seem to make any difference. This was actually the first thing I looked at when the problem occurred.

Regarding the z_position, this to be an int between 0 and 99, right? If so, is 99 the highest level? And do I have to assign a z_position to the other object as well to make a difference?

Unfortunately I currently don't have a repo to show but I'll see what I can do if I can't make it work soon. Thanks again @squidpunch !

squidpunch commented 8 years ago

the order doesnt matter? that seems pretty strange for sure, I've always been able to rely on these two things in the past.

zPosition is a float value, so it should be able to go as high as the max value

CGFLOAT_MAX
=> 1.79769313486232e+308

If you can get a repo together I can dig around a little more - if I have some time I will try and make a sample app and verify that something hasnt changed and im wrong :)

squidpunch commented 8 years ago

@andersennl I believe this should fix your problem. If you are still having a problem fell free to re-open this issue.