zoukankan      html  css  js  c++  java
  • 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];
            }
        }
    }
    
  • 相关阅读:
    mysql 启动不了,报错InnoDB相关
    vue 根据屏幕大小重新加载 echarts
    echarts 图例样式
    canvas 创建的图表,在移动端时,手指触碰,无法上下滑动页面
    uni-app 左上角返回按钮消失
    uni-app 缓存无法读取问题
    hbuider 运行 uni-app PC使用安卓模拟器接口请求错误
    wbstrom 使用git提交代码
    后端路由正常,但页面空白
    算法——RSA算法原理(转)
  • 原文地址:https://www.cnblogs.com/0515offer/p/4638323.html
Copyright © 2011-2022 走看看