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(@"點點點");

}

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容