The Gongge algorithm of ios-Interface building of the originator _ Nine

Source: Internet
Author: User

Steps to build nine Gongge:

Identify what the view is for each piece

Identify the parent-child relationship between each view

Try adding the grid one by one, and finally consider using the For loop

Load app data to create a corresponding number of squares based on the data length

Adding child controls inside a lattice

Assemble data to child controls inside the lattice

:

Code:

- (void) viewdidload{[SuperViewdidload];//Build interface-NINE!! #define KAPPVIEWH 80//Each small view high#define KAPPVIEWW 80//Each small view width#define KCOLCOUNT 3/Per line View number must be three#define Kstart 20//Adaptation screen, starting with    CGFloatMarginx = ( Self. View. Bounds. Size. Width-Kcolcount * kappvieww)/(Kcolcount +1);//The x value of each column must    CGFloatMarginy =Ten;//The Y value of each row must be determined by the line number     for(intI=0; i< A; i++) {//Line number        introw = I/kcolcount;//Column number        intcol = I%kcolcount;//x-determined by column number        CGFloatx = Marginx + col * (Kappvieww + Marginx);//y-determined by line number        CGFloaty = kstart + marginy + row * (KAPPVIEWH + marginy);//cgfloat        UIView*appview = [[UIViewAlloc]initwithframe:cgrectmake (x, Y, Kappvieww, KAPPVIEWH)]; Appview. BackgroundColor= [UicolorRedcolor]; [ Self. ViewAddsubview:appview]; }}

Operation Result:

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

The Gongge algorithm of ios-Interface building of the originator _ Nine

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.