iOS Development--full project actual combat OC & project Summary nine Gongge layout bilingual implementation

Source: Internet
Author: User

Project Summary of the nine Gongge layout bilingual implementationNine Gongge layout Create child controls
    • Implementation of version Objective-c
1  2  //Button3     //Data4Nsarray *images = @[@"Publish-video",@"publish-picture",@"Publish-text",@"Publish-audio",@"Publish-review",@"Publish-offline"];5Nsarray *titles = @[@"Send video",@"Send picture",@"Hair Satin",@"Hair Sound",@"Trial Posts",@"offline Download"];6    7     //some parameters8Nsuinteger count =Images.count;9     intMaxcolscount =3;//number of columns in a rowTenNsuinteger Rowscount = (count + maxcolscount-1) /Maxcolscount; One     A     //Button Size -CGFloat buttonw = [UIScreen mainscreen].bounds.size.width/Maxcolscount; -CGFloat Buttonh = buttonw *0.85; theCGFloat buttonstarty = ([uiscreen mainscreen].bounds.size.height-rowscount * buttonh) *0.5; -      for(inti =0; I < count; i++) { -         //Create, add -Xmgpublishbutton *button =[Xmgpublishbutton Buttonwithtype:uibuttontypecustom]; + [button addtarget:self action: @selector (ButtonClick:) forcontrolevents:uicontroleventtouchupinside]; - [Self.view Addsubview:button]; +         A         //Frame atCGFloat Buttonx = (i% maxcolscount) *buttonw; -CGFloat buttony = Buttonstarty + (i/maxcolscount) *Buttonh; -Button.frame =CGRectMake (Buttonx, Buttony, Buttonw, buttonh); -         -         //content - [button Setimage:[uiimage Imagenamed:images[i]] forstate:uicontrolstatenormal]; in [button settitle:titles[i] forstate:uicontrolstatenormal]; -}

    • Implementation of the Swift version
1var images:array<string> = ["Publish-video","publish-picture","Publish-text","Publish-audio","Publish-review","Publish-offline"]2var titles:array<string> = ["Send video","Send picture","Hair Satin","Hair Sound","Trial Posts","offline Download"]3 4         /** # array creation5 * var s1:array<string> = ["1", "2", "3"]6 * var s2:[string] = ["1", "2", "3"]//let7 * var s3 = [String] ()8 * /9 var Col:nsinteger = 3Ten var Count:nsinteger = 6 One          A Let totalloc:int = 3 - var vieww:cgfloat = self.view.frame.size.width/cgfloat (col) - var viewh:cgfloat = vieww + the          - For var i = 0; i < count; i++ -         { - var row:int = I/col + var loc:int = i% col -              + var viewx:cgfloat = vieww * CGFloat (Loc) + A var viewy:cgfloat = viewh * CGFloat (ROW) + at              - var Publish:icocospublishbutton = Icocospublishbutton (Frame:cgrectmake (viewX-0.5, Viewy-self.view.fra Me.size.height, ViewW-1, VIEWH)) -              - Self.view.addSubview (publish) -             - publish.setimage (UIImage (Named:images[i]), ForState:UIControlState.Normal) in Publish.settitle (Titles[i], forState:UIControlState.Normal) -       to Publish.tag = i + Publish.addtarget (Self, Action: "Publishbuttonclick:", ForControlEvents:UIControlEvents.TouchUpInside)  -              the Self.buttons.addObject (publish) *         } $ Panax Notoginseng     }

Copyright NOTICE: Welcome Reprint, please paste the source address: http://www.cnblogs.com/iCocos/(iOS DreamWorks)

For more highlights, please follow GitHub:https://github.com/al1020119?tab=repositories

iOS Development--full project actual combat OC & project Summary nine Gongge layout bilingual implementation

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.