UI4_LabelChess
//
// 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的更多相关文章
随机推荐
- mysql 加入列,改动列,删除列。
MySQL 加入列,改动列,删除列 ALTER TABLE:加入,改动,删除表的列,约束等表的定义. 查看列:desc 表名; 改动表名:alter table t_book rename to bb ...
- iOS开发——UI篇Swift篇&UIAlertView/UIActionSheet
UIAlertView/UIActionSheet UIAlertView //一个按钮的提醒 @IBAction func oneButtonAler() { //创建单一按钮提醒视图 let on ...
- 求1+2+3+...+n,要求不能使用乘除法、for、while、if、else、switch、case等关键字及条件判断语句(A?B:C)
代码如下: public int Sum_Solution(int n) { int temp = n; boolean b = (temp>0)&&(temp += Sum_S ...
- php与mysql通讯那点事
php与mysql通讯那点事 http://www.cnxct.com/libmysql-mysqlnd-which-is-best-and-what-about-mysqli-pdomysql-my ...
- 使用jmeter对ActiveMQ集群性能方案进行评估--转载
原文地址:http://www.51testing.com/html/78/23978-143163.html 1.测试概要1.1 关于这篇文档中涉及的基于JMS的消息系统能为应用程序提供可靠的,高性 ...
- HTML与Servlet
1.什么是servlet Servlet 是在服务器上运行的小程序.一个 Servlet 就是 Java 编程语言中的一个类,它被用来扩展服务器的性能,服务器上驻留着可以通过“请求-响应”编程模型来访 ...
- 1.7.5 Faceting
1. 分面(Faceting) 分面就是将搜索结果基于索引中的terms按类整理.搜索结果带有索引的term,没有term都带有该term匹配的文档数.分面使用户更容易探究搜索结果,缩小查询结果范围以 ...
- LOG4J.PROPERTIES配置详解(转载)
Log4J的配置文件(Configuration File)就是用来设置记录器的级别.存放器和布局的,它可接key=value格式的设置或xml格式的设置信息.通过配置,可以创建出Log4J的运行环境 ...
- iOS7.1 编译报错 解决方案 体会
iOS升级到 iOS 7.1 了 ,开发人员必须与时俱进.果断下载更新了xcode5.1版本 ,试运行了一下已上线的应用,哇 报错了!好头疼 贴下报错地方: 都是关于第三方类库报的错 比如parse. ...
- linux_cpu信息查询
查看cpu信息: [root@css-management ~]# cat /proc/cpuinfo processor : 0vendor_id : GenuineIntelcpu family ...