·您现在的位置: 云翼网络 >> 文章中心 >> 网站建设 >> app软件开发 >> IOS开发 >> 李冬强-用代码写view

李冬强-用代码写view

作者:佚名      IOS开发编辑:admin      更新时间:2022-07-23

主要代码

//

//  ViewController.m

//  创建view-709

//

//  Created by apple on 14-7-9.

//  Copyright (c) 2014年 戴维营教育. All rights reserved.

//

 

#import "ViewController.h"

 

@interface ViewController ()

            

 

@end

 

@implementation ViewController

            

- (void)viewDidLoad {

    [super viewDidLoad];

    // Do any additional setup after loading the view, typically from a nib.

//    CGPoint origin={0,0};

//    CGSize size={50,50};

//    CGRect rect={origin,size};

    

    UIView *yellView=[[UIView alloc]init];

    yellView.frame=CGRectMake(0, 0, 200, 200);

    yellView.backgroundColor=[UIColor yellowColor];

    [self.view addSubview:yellView];

    

    

    UIView *whiteView=[[UIView alloc]init];

    whiteView.frame=CGRectMake(0, 0, 100, 100);

    whiteView.backgroundColor=[UIColor grayColor];

    [yellView addSubview:whiteView];

    

    UIView *redView=[[UIView alloc]init];

    redView.frame=CGRectMake(100, 100, 100, 100);

    redView.backgroundColor=[UIColor redColor];

    [self.view addSubview:redView];

}

 

- (void)didReceiveMemoryWarning {

    [super didReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}

 

@end