Cat Learn iOS (v) UI 360 etc Download Manager nine grid UI

Source: Internet
Author: User

Cat Share, must boutique
Material: http://blog.csdn.net/u013357243/article/details/44486651

First look at the effect



The main is to complete the nine grid UI construction

Code
- (void) Viewdidload {[SuperViewdidload];//Nine the width of each lattice in the grid#define KAPPVIEWW//Nine the height of each lattice in the grid#define KAPPVIEWHHow many squares are there in the////nine lattice?#define KCOLCOUNT 3//Nine the first line of the grid from the top edge of the screen#define Kstarty    /* Idea: Place three controls in a view without wrapping through a double for loop, but by using the first and then judging his rows and columns to position his XY coordinates to complete 012 in line one: equivalent to I/kcolcount//row line: 122 lines:     3,453 rows: 678 int row = I/kcolcount;     Column: 362 columns: 147 int col = I%kcolcount; */    //per line interval    CGFloatMarginx = ( Self. View. Frame. Size. Width-KCOLCOUNT*KAPPVIEWW)/(kcolcount+1);//interval for each column    CGFloatMarginy =Ten; for(intI=0; i< A; i++) {//Row line: 122 lines: 3,453 lines: 678        introw = I/kcolcount;//Column column: 362 columns: 147        intcol = I%kcolcount;CGFloatx = Marginx + col* (MARGINX+KAPPVIEWW);//x coordinate of each view        CGFloaty = kstarty + +marginy + row * (Marginy + KAPPVIEWH);//y-coordinate of each view        UIView*appview = [[UIViewAlloc] Initwithframe:cgrectmake (x, Y, Kappvieww, KAPPVIEWH)]; [ Self. ViewAddsubview:appview];//Implement view interior details        nsdictionary*dict = Self. Applist[i];//Get every dictionary element in the Applist (Image caption Button image)        //uiimageview: Application picture        Uiimageview*icon = [[UiimageviewAlloc] Initwithframe:cgrectmake (0,0, KAPPVIEWW, -)];//icon. backgroundcolor = [Uicolor redcolor];Icon. Image= [UIImageimagenamed:dict[@"icon"]];//Set Picture        //Set picture fill modeIcon. Contentmode= Uiviewcontentmodescaleaspectfit;//fill's going to be bigger.[Appview Addsubview:icon];//uilabel: Application name        UILabel*label = [[UILabelAlloc] Initwithframe:cgrectmake (0, Cgrectgetmaxy (icon. Frame), KAPPVIEWW, -)]; Label. Text= dict[@"Name"]; Label. Font= [UifontSystemfontofsize:13.0]; Label. TextAlignment= Nstextalignmentcenter; [Appview Addsubview:label];//uibutton: Application Download button        UIButton*button = [[UIButtonAlloc] Initwithframe:cgrectmake (0, Cgrectgetmaxy (label. Frame), KAPPVIEWW, -)]; [Button setbackgroundimage:[UIImageimagenamed:@"Buttongreen"] Forstate:uicontrolstatenormal]; [Button setbackgroundimage:[UIImageimagenamed:@"buttongreen_highlighted"] forstate:uicontrolstatehighlighted]; [Button settitle:@"Download"Forstate:uicontrolstatenormal];//* * * Do not use the following methods to modify the button title        //Button.titleLabel.text = @ "AAA";        //Modify font (Titlelabel is read-only)        //ReadOnly indicates that the Titlelabel pointer is not allowed, but the font of the label can be modified        //Hint: The font of the button is not state-sensitive! button. Titlelabel. Font= [UifontSystemfontofsize:12.0];      [Appview Addsubview:button]; }    }
Ideas

Idea: Put three controls in a view
Does not wrap through a double for loop, but passes through the first and then judges his row and column to locate his XY coordinate complete
012 in the first line: equivalent to I/kcolcount
Row line: 122 lines: 3,453 lines: 678
int row = I/kcolcount;
Column: 362 columns: 147
int col = I%kcolcount;

Algorithm analysis diagram

Watch out.

Setting the picture and setting the picture is a little different, if the last set to Uiviewcontentmodescaleaspectfit will be beyond the defined border, according to the original pixel size to decorate.
Icon.image = [UIImage imagenamed:dict[@ "icon"];
Icon.contentmode = Uiviewcontentmodescaleaspectfit;

Font settings for Uilabel;uibutton
        //设置标题        label.text = dict[@"name"];        //设置字体大小        label.font = [UIFont systemFontOfSize:13.0];        //设置Label居中        label.textAlignment = NSTextAlignmentCenter;

button font settings

[button setTitle:@"下载" forState:UIControlStateNormal];        // *** 一定不要使用以下方法,修改按钮标题        //        button.titleLabel.text = @"aaa";        // 修改字体(titleLabel是只读的)        // readonly表示不允许修改titleLabel的指针,但是可以修改label的字体        // 提示:按钮的字体是不区分状态的!        button.titleLabel.font = [UIFont systemFontOfSize:12.0];

Not to be continued ....

PS1: There are those who want the source can add cat Znycat QQ can also: 1764541256
--Video learning materials free analysis, ah, I'm lonely learning! Meow!!!
PS2: Last night with the classmate computer to see how he wrote, found that csdn unexpectedly into not go, meow a cat cat drunk, more drunk is found in other sites have reproduced, instant chicken frozen meow.

Cat Learn iOS (v) UI 360 etc Download Manager nine grid UI

Related Article

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.