iphone添加视图实例

-(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];

}

One thought on “iphone添加视图实例

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注