//
// AppDelegate.m
// UI4_LabelChess
//
// Created by zhangxueming on 15/6/29.
// Copyright (c) 2015年 zhangxueming. All rights reserved.
// #import "AppDelegate.h" @interface AppDelegate () @end @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// [self showLabelChess];
[self printShow];
self.window.rootViewController = nil;
self.window.backgroundColor = [UIColor whiteColor];
return YES;
} - (void)showLabelChess
{
CGFloat width= self.window.frame.size.width/8;
NSArray *textArray = @[@"車",@"马",@"象",@"王",@"后",@"象",@"马",@"車"];
for (int i=0; i<8; i++) {
for(int j=0;j<8; j++) {
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(j*width, i*width+20, width,width)];
if ((i+j)%2) {
label.backgroundColor = [UIColor yellowColor];
}
else
{
label.backgroundColor = [UIColor greenColor];
} if(i==0||i==7)
{
label.text = textArray[j];
label.textAlignment = NSTextAlignmentCenter;
}
if (i==1||i==6) {
label.text = @"兵";
label.textAlignment = NSTextAlignmentCenter;
} if (i==0||i==1) {
label.textColor = [UIColor redColor];
} if (i==6||i==7) {
label.textColor = [UIColor blueColor];
}
[self.window addSubview:label];
}
}
} -(void)printShow
{
CGFloat length=self.window.frame.size.width/9;
for(int i=0;i<9;i++)
{
for(int j=0;j<=i;j++)
{
UILabel *lable1 =[[UILabel alloc] initWithFrame:CGRectMake(j*length, i*length+20, length-1, length-1)];
lable1.text=[[NSString alloc]initWithFormat:@"%d*%d=%d", (i+1),(j+1),(i+1)*(j+1)];
lable1.backgroundColor=[UIColor blueColor];
lable1.adjustsFontSizeToFitWidth=YES;
[self.window addSubview:lable1];
}
}
}

UI4_LabelChess的更多相关文章

随机推荐

  1. Java中类的初始化顺序

    一.一个类的初始化顺序(没继承情况)  规则: 1.静态变量>普通变量>构造方法   2.变量定义的顺序决定初始化的顺序 3.静态变量和静态块是一样的,普通变量和非静态块是一样的,即能够把 ...

  2. OC和JS之间的交互

    OC和JS之间的交互 目录 对OC和JS之间交互的理解 JS调用OC OC调用JS 对OC和JS之间交互的理解 JS调用OC JS文件 function sendCommand(cmd,param){ ...

  3. Ubuntu Nginx搭建Gitweb服务器

    安装Nginx 和 Gitweb   simba@simba-laptop:~$ sudo apt-get install nginx gitweb   修改Gitweb配置文件 simba@simb ...

  4. Sleep v.s. sleep

    Sleep函数_百度百科 http://baike.baidu.com/link?url=EmOxsG_du8HdLbv_9nDVlahpZOQ6DgkoLKooQInorAqIl_CEhCvBzTC ...

  5. http协议学习(一)http状态

    整理了一个脑图,算作是<图解HTTP>的读书笔记,这本书有很多插图,适合初学者入门理解. 讲解网络协议的书不多 其中两本被人们奉为圣经  <TCP/IP详解 卷一> <H ...

  6. EF——继承映射关系TPH、TPT和TPC的讲解以及一些具体的例子 05 (转)

    EF里的继承映射关系TPH.TPT和TPC的讲解以及一些具体的例子   本章节讲解EF里的继承映射关系,分为TPH.TPT.TPC.具体: 1.TPH:Table Per Hierarchy 这是EF ...

  7. K - Ancient Messages(dfs求联通块)

    K - Ancient Messages Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Subm ...

  8. Sum of divisors

    Problem Description mmm is learning division, she's so proud of herself that she can figure out the ...

  9. myecplise 打开报错 Errors occurred during the build. Errors running builder 'DeploymentBuilder' on project 'myf'. Java.lang.NullPointerException

    Errors occurred during the build. Errors running builder 'DeploymentBuilder' on project 'myf'.Java.l ...

  10. 修改avd路径

    1.比如你要把AVD放在D盘AndroidAVD下面,则预先在D盘下建立一个文件夹 AndroidAVD.必须的.不然设置了环境变量也没有用,因为模拟器不会自动创建该文件夹. 2.在桌面右击“我的电脑 ...