• iOS 九宫格的实现


    #import <UIKit/UIKit.h>

    @interface ViewController : UIViewController

    @property(strong,nonatomic) UILabel *lblNums;

    @end

    #import "ViewController.h"

    @interface ViewController ()

    @end

    @implementation ViewController

    - (void)viewDidLoad {

        [super viewDidLoad];

     int x=50,y=50,width=50,height=50;

        int a=1;

        for (int i=0; i<3; i++)

        {

            for (int j=0;j<3; j++)

            {

                self.lblNums=[[UILabel alloc] initWithFrame:CGRectMake(x+j*55, y+i*55, width, height)];

                

               self.lblNums.backgroundColor=[UIColor colorWithRed:(arc4random()%12/11.0) green:(arc4random()%23/22.0) blue:(arc4random()%34/33.0) alpha:1.0];

                

                NSString *newnum=[@(a) stringValue];

                    self.lblNums.text=newnum;

                    self.lblNums.textAlignment=1;

                    a++;

                    [self.view addSubview:self.lblNums];

            }

        }

        

    }

  • 相关阅读:
    DIV+CSS中的滤镜和模糊
    初识DIV+CSS
    HTML核心标签之表格标签(二)
    HTML核心标签之表格标签(一)
    关于HTML的两个实例
    CSS的四种引入方式
    HTML中的表单
    HTML基础知识概括
    python3操作socketserver
    数据库MySQL的基本操作
  • 原文地址:https://www.cnblogs.com/tmf-4838/p/5330550.html
Copyright © 2020-2023  润新知