//UIViewController 視圖控制器
//抽象類:不能直接通過創(chuàng)建使用創(chuàng)建對象? 需要定義該類的子類? 然后在創(chuàng)建對象使用
//創(chuàng)建vc對象
//? ? UIViewController *vc = [[UIViewController alloc] init];
// 創(chuàng)建對象
RootViewController *rootVC = [[RootViewController alloc] init];
// 設(shè)置根視圖(應(yīng)用創(chuàng)建好之后? window上放置的第一個(gè)頁面視圖)
self.window.rootViewController = rootVC;
[rootVC release];
[_window release];
return YES;
}
#import "RootViewController.h"
@interface RootViewController ()
@end
@implementation RootViewController
#warning 重點(diǎn): 以后視圖寫在viewDidLoad中
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
//VC中自帶一個(gè)view 用于鋪設(shè)視圖 默認(rèn)顏色為透明
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"];
//手獲路徑(動態(tài)變化的路徑)
//參數(shù)一: 文件名? 參數(shù)二: 文件后綴
NSString *path = [[NSBundle mainBundle] pathForResource:@"super" ofType:@"jpg"];
imgView.image = [UIImage imageWithContentsOfFile:path];
// 圓角
imgView.layer.cornerRadius = imgView.frame.size.width/2;
//根據(jù)邊界不多余部分切掉
imgView.clipsToBounds = YES;
}
//button 觸發(fā)方法
-(void)click{
NSLog(@"點(diǎn)點(diǎn)點(diǎn)");
}