问题
I've got a CCScene with few UIKit elements [UITextView for example]. After some user interaction I want to open a popup over the scene to also cover part of the UITextView. It doesn't matter what z index I am using, it will always appear under the text view. Any tips on how to do it?
回答1:
Your CCNodes are drawn within the EAGLView Cocos is using. You need to manage the order of EAGLView(s) relative to other UIViews. Take a look at http://www.gdcvault.com/play/1012504/The-Best-of-Both-Worlds for an example of mixing Cocos drawing in EAGLViews with other UIKit views.
回答2:
Another thought, and I'm saying this off the top of my head without trying first...
From memory, you can, from a UIView get an image of that views contents. If, after the user interaction is done and you want to place your popup over the text field, you could create an UIimage from it, turn that into a texture, create a ccsprite from that and place it in the sam e spot on the screen. You could then hide the actual text field and then pop up your popup. The user wouldn't be able to tell the difference.
来源:https://stackoverflow.com/questions/7987519/cocos2d-node-over-uikit-element