import“ViewController.h"
@interface ViewController()
@end
@implementation ViewController
-(void)viewDidload
{
[super viewDidload];
UIView *redview=[[UIView alloc]init];
redview.frame=CGRectMake(0,0,300,100);
redview.backgroundcolor=[UIColor redColor];
[self.view addSubview:redview];
UIView *greenview=[[UIView alloc]init];
greenview.frame=CGRectMake(0,100,150,100);
greenview.backgroundColor=[UIColor greenColor];
[redview addSubview:greenview];
UIView *whiteview=[[UIView alloc]init];
whiteview.frame=CGRectMake(150,100,150,100);
whiteview.backgroundColor=[UIColor blackColor];
[self.view addSubview:whiteview];
}
原文地址:http://www.cnblogs.com/sunxiang1991/p/3834997.html