iPhoneアプリ開発初心者のブログ

プログラミング未経験の文系アラフォー会社員によるiPhoneアプリ開発日記

iPhoneの画面に色をつけるプログラム

f:id:myup:20110526100120j:plain

 

今日は

 

Code School - Try iOS

 

iPhoneの画面に色をつけるプログラムをやりました。

 

お絵かきに例えていたのがわかり易いです。

 

例えば、

 CGRect viewRect = [[UIScreen mainScreen] bounds];

    self.window = [[UIWindow alloc] initWithFrame:viewRect];

はキャンバス。

 

 UIViewController *viewController = [[UIViewController alloc] init];

    [self.window makeKeyAndVisible];

は絵筆。

 

UIViewController *viewController = [[UIViewController alloc] init];

    UIView *view = [[UIView alloc] initWithFrame:viewRect];

 

    view.backgroundColor = [UIColor lightGrayColor];

 

    viewController.view = view;

はパレット、といった感じ。

 

 

全体のコードは以下になります。

 

#import "AppDelegate.h"

 

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

{

    CGRect viewRect = [[UIScreen mainScreen] bounds];

    self.window = [[UIWindow alloc] initWithFrame:viewRect];

    UIViewController *viewController = [[UIViewController alloc] init];

    UIView *view = [[UIView alloc] initWithFrame:viewRect];

 

    view.backgroundColor = [UIColor lightGrayColor];

 

    viewController.view = view;

 

    self.window.rootViewController = viewController;

    [self.window makeKeyAndVisible];

 

    NSLog(@"Screen is %f tall and %f wide", viewRect.size.height, viewRect.size.width);

 

    return YES;

}

@end

 

引き続き頑張ります。

 

 

iPhoneプログラミングUIKit詳解リファレンス

iPhoneプログラミングUIKit詳解リファレンス