Game Development Reference
In-Depth Information
UITextField* textFieldFront = [[UITextField alloc] initWithFrame:←
CGRectMake(280, 40, 200, 24)];
textFieldFront.text = @" On top of Cocos2D";
textFieldFront.borderStyle = UITextBorderStyleRoundedRect;
textFieldFront.delegate = self;
[window addSubview:textFieldFront];
Actually, you could also add the textFieldFront to the glView as a subview
without any immediately noticeable change. But adding the text field to the window
allows you to reorder it in the view hierarchy at any time; for example, you could move
it behind the cocos2d view using the sendSubviewToBack method of the window .
You wouldn't be able to do that if you add the view directly to cocos2d's glView .
Check out Figure 15-3 for the result. You'll have UIKit views on top of the cocos2d
view and behind it. The text view at the back can still be edited and manipulated as the
Cut, Copy, Paste, Replace button shows. More importantly, despite the accompanying
text field being behind the cocos2d view, the Cut, Copy, Paste, Replace pop-over but-
ton is automatically on top of the cocos2d view. Just how it ought to be!
Figure 15-3 . UIKit views on top and behind the cocos2d view, with input enabled for all of them
Adding Views Designed with Interface Builder
 
 
Search Nedrilad ::




Custom Search