UIViewController

//UIViewController 视图控制器

//抽象类:不能直接通过创建使用创建对象  需要定义该类的子类  然后在创建对象使用

//创建vc对象

//    UIViewController *vc = [[UIViewController alloc] init];

// 创建对象

RootViewController *rootVC = [[RootViewController alloc] init];

// 设置根视图(应用创建好之后  window上放置的第一个页面视图)

self.window.rootViewController = rootVC;

[rootVC release];

[_window release];

return YES;

}

#import "RootViewController.h"

@interface RootViewController ()

@end

@implementation RootViewController

#warning 重点: 以后视图写在viewDidLoad中

- (void)viewDidLoad {

[super viewDidLoad];

// Do any additional setup after loading the view.

//VC中自带一个view 用于铺设视图 默认颜色为透明

self.view.backgroundColor = [UIColor cyanColor];

UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];

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

btn.backgroundColor = [UIColor yellowColor];

[btn addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside];

[self.view addSubview:btn];

// UIImageView 图片

UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(100, 200, 200, 200)];

imgView.backgroundColor = [UIColor yellowColor];

[self.view addSubview:imgView];

[imgView release];

//添加图片

//相对路径:修改之后仍可以找到

//绝对路径: 如果文件位置修改 就找不到啦

//    imgView.image = [UIImage imageNamed:@"super.jpg"];

//手获路径(动态变化的路径)

//参数一: 文件名  参数二: 文件后缀

NSString *path = [[NSBundle mainBundle] pathForResource:@"super" ofType:@"jpg"];

imgView.image = [UIImage imageWithContentsOfFile:path];

// 圆角

imgView.layer.cornerRadius = imgView.frame.size.width/2;

//根据边界不多余部分切掉

imgView.clipsToBounds = YES;

}

//button 触发方法

-(void)click{

NSLog(@"点点点");

}

你可能感兴趣的:(UIViewController)