动态创建View的方法,包括Button等等

创建 myView:

UIVIew *myView = [[UIView alloc] initWithFrame:CGRectMaker(0,0,100,100)];
[anyView  addSubview:myView];
[myView release];

销毁myView;
[myView removeFromSuperview];


在view中创建button:

UIButton *btn = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];
btn.frame = CGRectMake(60,60, 60, 60);
[self.view addSubview:btn];

在view中销 毁button:
[btn removeFromSuperview];
[btn release];

你可能感兴趣的:(动态创建View的方法,包括Button等等)