您的位置:首页 > 移动开发 > Cocos引擎

Cocos2d怎样使用原生态的控件

2012-11-08 19:09 218 查看
这个不难实现.只要你得到当前的视图,然后在这个视图上添加你想要的视图控件.

UIView *view=[[DirectorsharedDirector] openGLView];

新的cocos2d 2.0为

UIView *view=[[DirectorsharedDirector] view];

UIScrollView *scrollview = [[UIScrollView alloc] initWithFrame:CGRectMake(260, 50, 150, 250)];

UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(20, 50, 72, 103)];

scrollview.contentSize = CGSizeMake(150, 252);

imageView.image = [UIImage imageNamed:@"BtnVirus.png"];

[scrollview addSubview:imageView];

[[[CCDirector sharedDirector] view] addSubview:scrollview];

要移除

[scrollview removeFromSuperview];

移除添加进来控件的写法

UIView* object;

object.tag = kObjTag;

[[[[CCDirector sharedDirector]openGLView] window]addSubview:object];//添加

[[[[[CCDirector sharedDirector]openGLView] window]viewWithTag:kObjTag]removeFromSuperview];//根据tag值移除
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  cocos2d