iOS Dev (32) 画个棋盘

iOS Dev (32) 画个棋盘

  • 作者:CSDN 大锐哥
  • 地址:http://blog.csdn.net/prevention

-

本人愚钝,写个非常简单的 UIView 的练习例子,也得写篇博文。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

    for (int i = 0; i < 10; ++i)
    {
        for (int j = 0; j < 10; ++j)
        {
            UIView *view = [[UIView alloc] initWithFrame:CGRectMake(32 * i, 20 + 32 * j, 32, 32)];
            view.backgroundColor = ((i + j) % 2) ? [UIColor blackColor] : [UIColor grayColor];
            [self.window addSubview:view];
        }
    }

    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    return YES;
}

运行下看看效果图吧:

iOS Dev (32) 画个棋盘_第1张图片

-

转载请注明来自:http://blog.csdn.net/prevention

你可能感兴趣的:(iOS Dev (32) 画个棋盘)