iOS初始化UIView

来源:互联网 发布:win10软件闪退 编辑:程序博客网 时间:2024/05/21 03:57

     UiView是iOS中很多控件的父类,能够绘制出很多的图形,具体如何来初始化呢?

#import "ViewController.h"@interface ViewController ()@end@implementation ViewController- (void)viewDidLoad {  [super viewDidLoad];    //视图;  UIView *view1 = [[UIView alloc] init];  //位置大小;  view1.frame = CGRectMake(0, 0, 200, 300);  //背景颜色;  view1.backgroundColor = [UIColor yellowColor];    //将视图加入到父视图中;  [self.view addSubview:view1];  }@end

运行效果如下:


github主页:https://github.com/chenyufeng1991  。欢迎大家访问!

1 0
原创粉丝点击