Reputation: 22290
I have a phase in my app where I need to "sync" with a device. During this interval, I want to a) prevent the user from touching things and b) show some progress of the sync operation.
I made a custom UIView that shows my percentage feedback and placed it in the view tree at the appropriate place. That solves (b).
For (a), I simply slap a UIView over the top of everything
myController.view.addSubview(newView)
and manipulate it's alpha value. By using a semi-transparent color/alpha value, I can "gray out" the app.
BUT, I wanted my feedback control to still show "full color". I thought I could simply adjust the layer.zPosition
of said view to get it to draw "above" the masking/blocking/graying view.
myFeedbackView.layer.zPosition = 100.0
Unfortunately, this does not seem to work. Using a 50% alpha blue for the guard view, the feedback view is not bright full color as hoped.
I had thought that zPosition
trumped placement in the subviews. Is that only within a given container? I assumed it was global to all views (and their associated layers) on the screen.
Upvotes: 4
Views: 1494
Reputation: 22290
After some experimentation with simple color tiles, I think I've come to the conclusion that the order views are drawn in is done at each container level. At that level, zPosition is used first, and subview order is used secondarily (when the zPosition matches). But this is only in the context of a single set of subviews. The container of those subviews will be arbitrated against its siblings based on the same criteria. I wish Apple documentation had made this more clear. But maybe I just wasn't digging deep enough.
Upvotes: 7