//
// 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. epoll的使用

      http://blog.csdn.net/ljx0305/article/details/4065058 epoll - I/O event notification facility 在linu ...

  2. Linux下杀僵尸进程办法

    1) 检查当前僵尸进程信息 # ps -ef | grep defunct | grep -v grep | wc -l 175 # top | head -2 top - 15:05:54 up 9 ...

  3. android之存储篇——SQLite数据库

    转载:android之存储篇_SQLite数据库_让你彻底学会SQLite的使用 SQLite最大的特点是你可以把各种类型的数据保存到任何字段中,而不用关心字段声明的数据类型是什么. 例如:可以在In ...

  4. Java获取当前进程的所有线程

    public class MainClass { public static void main(String[] args) { ThreadGroup group = Thread.current ...

  5. 小白日记45:kali渗透测试之Web渗透-SqlMap自动注入(三)-sqlmap参数详解-Optimization,Injection,Detection,Techniques,Fingerprint

    sqlmap自动注入 Optimization [优化性能参数,可提高效率] -o:指定前三个参数(--predict-output.--keep-alive.--null-connection) - ...

  6. E - 娜娜梦游仙境系列——莫名其妙的插曲

    E - 娜娜梦游仙境系列——莫名其妙的插曲 E - 娜娜梦游仙境系列——莫名其妙的插曲 Time Limit: 2000/1000MS (Java/Others)    Memory Limit: 1 ...

  7. 通过布赛尔曲线以及CAShapeLayer的strokeStart 、strokeEnd 属性来实现一个圆形进度条

    #import <UIKit/UIKit.h> @interface CircleProgressView : UIView /**起始值(0-1)*/ @property(nonatom ...

  8. MFC简易画图

    开发一个MFC绘图程序,基于"文档-视图"结构,在客户区能够完成: ①画直线 ②画矩形 ③画圆(椭圆) ④画任意折线(右键结束) ⑤画任意多边形(右键结束,并形成闭环) 注:图形中 ...

  9. Redis入门(集合)

    集合 Redis的集合是字符串的无序集合.在Redis您可以添加,删除和测试文件是否存在,在成员O(1)的时间复杂度. 例子 redis 127.0.0.1:6379> sadd tutoria ...

  10. Unhandled Error in Silverlight Application “Syncfusion.Silverlight.Olap.Gauge.OlapGauge”的类型初始值设定项引发异常

    Silverlight 在运行时,如果出现如下错误: 检查生成的xap文件,解压出来,看是否里面包含该DLL:Syncfusion.Silverlight.Olap.Gauge.OlapGauge