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的更多相关文章
随机推荐
- IPC——共享内存
Linux进程间通信——使用共享内存 下面将讲解进程间通信的另一种方式,使用共享内存. 一.什么是共享内存 顾名思义,共享内存就是允许两个不相关的进程访问同一个逻辑内存.共享内存是在两个正在运行的 ...
- MapReduce原理及其主要实现平台分析
原文:http://www.infotech.ac.cn/article/2012/1003-3513-28-2-60.html MapReduce原理及其主要实现平台分析 亢丽芸, 王效岳, 白如江 ...
- 一款基于jQuery的支持鼠标拖拽滑动焦点图
记得之前我们分享过一款jQuery全屏广告图片焦点图,图片切换效果还不错.今天我们要分享另外一款jQuery焦点图插件,它的特点是支持鼠标拖拽滑动,所以在移动设备上使用更加方便,你只要用手指滑动屏幕即 ...
- UIView的生命周期总结
序言: loadView.viewDidLoad.viewDidAppear.initWithNibName.awakeFromNib等经常出现在UIViewController中的方法介绍. 这些方 ...
- Unity3D 使用脚本来控制 UI 的 Image 显示的图片。
记录一下这个问题. 原文地址:http://tieba.baidu.com/p/3561719701 object obj = Resources.Load(资源名, typeof(Sprite)); ...
- MySQL(22):事务管理之 事务回滚
1. 在操作事务的时候,如果发现当前事务操作是不合理的,此时只要还没有提交事务,就可以通过回滚取消当前事务,接下来就针对事务的回滚进行详细讲解. 2. 为了演示回滚操作,在上一个笔记案例基础之上,此时 ...
- Web分布式部署,跨应用程序Forms身份验证的集成方案
最近一个项目要求进行分布式部署.保证在双十一期间系统的正常运行,虽然该系统平时访问量不是很大,但是基于业务需要,必须在至少两台服务器上部署. 该系统需要登录后才可以使用,首先需要解决分布式部署的用户状 ...
- Operation与GCD的不同
最大并发数: 什么是并发数? 同时执行的任务数.比如同时开启三个线程执行三个任务,并发数就是3. 最大并发数相关的方法: -(NSInteger)maxConcurrentOperationCount ...
- redis存储对象,实体类新加字段空指针问题处理
redis是一个key-value存储系统.和Memcached类似,它支持存储的value类型相对更多,包括string(字符串).list(链表).set(集合).zset(sorted set ...
- java 生成UUID
UUID(Universally Unique Identifier)全局唯一标识符,是一个128位长的数字,一般用16进制表示. 算法的核心思想是结合机器的网卡.当地时间.一个随即数来生成UUID, ...