zoukankan      html  css  js  c++  java
  • iOS常用技术-国际象棋布局

     1 //
     2 //  ViewController.m
     3 //  国际象棋
     4 //
     5 //  Created by 大欢 on 16/1/19.
     6 //  Copyright © 2016年 bjsxt. All rights reserved.
     7 //
     8 
     9 #import "ViewController.h"
    10 
    11 @interface ViewController ()
    12 
    13 @end
    14 
    15 @implementation ViewController
    16 
    17 - (void)viewDidLoad {
    18     
    19     [super viewDidLoad];
    20    
    21     NSArray * array = @[@"",@"",@"",@"",@"",@"",@"",@""];
    22     
    23     CGFloat width = CGRectGetWidth(self.view.frame)/8;
    24     
    25     for (int i = 0; i < 8; i++) {
    26         for (int j = 0; j < 8;j++) {
    27             
    28             UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(j * width, i * width + 20, width, width)];
    29             label.textAlignment = NSTextAlignmentCenter;
    30             if ((i + j)%2 == 0) {
    31                 label.backgroundColor = [UIColor blackColor];
    32             } else {
    33                 label.backgroundColor = [UIColor whiteColor];
    34             }
    35             
    36             if (i == 0 || i == 7) {
    37                 label.text = array[j];
    38             }
    39             
    40             if (i == 1 || i == 6) {
    41                 label.text = @"";
    42             }
    43             
    44             if (i == 0 || i == 1) {
    45                 label.textColor = [UIColor redColor];
    46             }
    47             
    48             if (i == 6 || i == 7) {
    49                 label.textColor = [UIColor greenColor];
    50             }
    51  
    52             [self.view addSubview:label];
    53         }
    54     } 
    55 }
    56 @end


  • 相关阅读:
    向量场中的积分
    Oracle 动态视图4 V$SESSION_WAIT & V$SESSION_EVENT
    Oracle 动态视图3 V$SESSION
    Oracle 动态视图2 V$LOCKED_OBJECT
    Oracle 摘去数据块的面纱
    Oracle 动态视图1 V$LOCK
    Oracle Lock 概述
    Oracle 监听动态注册与静态注册
    Oracle用户进程跟踪
    Oracle SGA参数调整
  • 原文地址:https://www.cnblogs.com/MrWuYindi/p/5146513.html
Copyright © 2011-2022 走看看