-(IBAction)createView:(id)sender{
//新加视图位位置
CGRect frame = CGRectMake(50, 200, 200, 20);
//一个文本标签
UILabel *label = [[UILabel alloc]initWithFrame:frame];
//添加到窗口上
[self.view addSubview:label];
[label setText:@”这是动态加上去的视图“];
[label setBackgroundColor:[UIColor blueColor]];
label.textColor = [UIColor redColor];
}
iphone添加视图实例 – 果冻空间