#define Screenw [UIScreen mainscreen].bounds.size.width#define screenh [UIScreen mainscreen].bounds.size.height
1 //Data2Nsarray *images = @[@"Publish-boke",@"publish-weixin",@"PUBLISH-QQ",@"Publish-offline"];3Nsarray *titles = @[@ "Send blog",@"Hair",@"Send QQ",@"offline Download"];4 5 //6 buttons in the middle6 intMaxcols =3;7CGFloat buttonw = the;8CGFloat Buttonh = buttonw + -;9CGFloat Buttonstarty = (SCREENH-2* Buttonh) *0.5;TenCGFloat Buttonstartx = -; OneCGFloat Xmargin = (SCREENW-2* Buttonstartx-maxcols * buttonw)/(Maxcols-1); A for(inti =0; i<images.count; i++) { -Verticalbutton *button =[[Verticalbutton alloc] init]; - //Set Content theButton.titleLabel.font = [Uifont systemfontofsize: -]; - [button settitle:titles[i] forstate:uicontrolstatenormal]; - [button Settitlecolor:[uicolor Blackcolor] forstate:uicontrolstatenormal]; - [button Setimage:[uiimage Imagenamed:images[i]] forstate:uicontrolstatenormal]; + - //Set Frame +Button.width =buttonw; AButton.height =Buttonh; at introw = I/Maxcols; - intCol = i%Maxcols; -button.x = Buttonstartx + col * (Xmargin +buttonw); -BUTTON.Y = buttonstarty + row *Buttonh; - [Self.view Addsubview:button]; -}
iOS Code Implementation IX Gongge