IOS Custom Nine Gongge

Source: Internet
Author: User

/** Here we use button to do because many times need to text also need to display the picture, so button more appropriate */-(void) creatorbtn{//Number of columns Nsinteger column = 4;        Number of buttons Nsinteger buttoncount = 18;    The width and height of the button cgfloat buttonw = Self.view.frame.size.width/column;        CGFloat buttonh = buttonw;                for (int i = 0; i < Buttoncount; i++) {UIButton *btn = [UIButton buttonwithtype:uibuttontypecustom];                        Btn.frame = CGRectMake ((((i) column) * buttonw), ((i/column) * buttonh), buttonW-10, buttonH-10);                NSLog (@ "%@", Nsstringfromcgrect (Btn.frame));                [Btn Setbackgroundcolor:[uicolor Redcolor];                Bind tag, listen behind Click Btn.tag = i;                        [Self.view ADDSUBVIEW:BTN];            Listen button click [btn addtarget:self Action: @selector (btnaction:) forcontrolevents:uicontroleventtouchupinside];    }}-(void) Btnaction: (UIButton *) btn{//According to the button's tag to listen for click NSLog (@ "Clicked the%ld button", (long) btn.tag); }

IOS Custom Nine Gongge

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.