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的更多相关文章
随机推荐
- nested exception is java.io.FileNotFoundException: class path resource [spring/spring-datasource-mog
spring单元測试时发现的问题: org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsin ...
- JavaScript模块化开发一瞥
对于那些正在构建大型应用程序,而对JavaScript不甚了解的开发者而言,他们最初必须要面对的挑战之一就是如何着手组织代码.起初只要在标记之间嵌入几百行代码就能跑起来,不过很快代码就会变得一塌糊涂… ...
- 动漫网站基于jquery的横向手风琴特效
今天给大家分享一款动漫网站基于jquery的横向手风琴特效.这款手风琴特效适用浏览器:IE8.360.FireFox.Chrome.Safari.Opera.傲游.搜狗.世界之窗.效果图如下: 在线预 ...
- 代码片段 - Golang 创建 .tar.gz 压缩包
Golang创建 .tar.gz 压缩包 tar 包实现了文件的打包功能,可以将多个文件或目录存储到单一的 .tar 文件中,tar 本身不具有压缩功能,只能打包文件或目录: import " ...
- C# 之 System.Diagnostics.Process.Start的妙用
经常会遇到在Winform或是WPF中点击链接或按钮打开某个指定的网址, 或者是需要打开电脑中某个指定的硬盘分区及文件夹, 甚至是"控制面板"相关的东西, 如何做呢? 方法:使用S ...
- js数组的管理[增,删,改,查]
今天在设计表单的时候遇到对数组的一些处理的问题,比如说怎么创建一个数组,然后牵扯到数组的增删改查的方法.请看API FF: Firefox, N: Netscape, IE: Internet Exp ...
- 修改Intellij Idea 创建maven项目默认Java编译版本
在使用Intellij Idea 创建Maven项目时,默认的Java Language是1.5,虽然可以在Project Structrue中修改,但是每次pom.xml文件有变化时,工程又会重置到 ...
- WPF之鼠标滑动切换图片
在网上找了一会儿也没找到我想要的效果,还是自己动手,丰衣足食吧. 需求:当前面板中只显示一张图片,图片栏的下部有用来显示当前图片处于图片队列中的位置的圆球,并且点击下部栏内的圆球可以快速切换,附动画缓 ...
- 通过pinyin4j将汉字转换为全拼 和 拼音首字母
/** * 汉字转换为拼音 包含多音字,包含生母zh,ch,sh的 */ public void toPinYinAll(){ String initials = "zh,ch,sh&quo ...
- IOS 弹出菜单的动态效果
效果1.点击按钮上浮 2.点击按钮下沉 3.点击按钮下拉展示 4.点击按钮向上收缩 5.左右如是说 关键是改变视图的大小位置的时机正确与否 eg1.1.点击按钮下沉消失 已知myView.frame= ...