首页 > 其他 > 详细

UIView实现红黑棋盘

时间:2015-08-15 21:36:47      阅读:276      评论:0      收藏:0      [点我收藏+]

//  Created by 妖精的尾巴 on 15-8-15.

//  Copyright (c) 2015 妖精的尾巴. All rights reserved.

//


#import "ViewController.h"

#define kHeight 20

@interface ViewController ()

@end


@implementation ViewController


- (void)viewDidLoad

{

    [super viewDidLoad];

    UIView* view=[[UIView alloc]initWithFrame:CGRectMake(0, kHeight, 320, 320)];

    view.backgroundColor=[UIColor redColor];

    [self.view addSubview:view];

    for (int col=0; col<320; col+=40) {

        for (int row=0; row<320; row+=40)

        {

            UIView* redView=[[UIView alloc]initWithFrame:CGRectMake(row, col, kHeight, kHeight)];

            redView.backgroundColor=[UIColor blackColor];

            [view addSubview:redView];

        }

        for (int row=20; row<320; row+=40)

        {

            UIView* redView=[[UIView alloc]initWithFrame:CGRectMake(row, col+kHeight, kHeight, kHeight)];

            redView.backgroundColor=[UIColor blackColor];

            [view addSubview:redView];

        }

    }

}

技术分享

UIView实现红黑棋盘

原文:http://my.oschina.net/iOSliuhui/blog/492993

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!