iOS九宫格布局
for (int i=0; i<[self.imagearray count]; i++) {
UIButton *button = [UIButton buttonWithType: UIButtonTypeRoundedRect];
button.frame = CGRectMake(i%3*(SCREEN_WIDTH/3-1), i/3*(SCREEN_WIDTH/3-1)+self.view2.frame.origin.y+self.view2.frame.size.height+5,SCREEN_WIDTH/3-1,SCREEN_WIDTH/3-1);
self.Statebutton=button1;
NSString *str = [_imagearray objectAtIndex:i];
button.tag =i;
[button setBackgroundImage:[UIImage imageNamed:[[IhuikouPublicTools getImagePath]stringByAppendingPathComponent:str]]forState:UIControlStateNormal];
[button addTarget:self action:@selector(change:) forControlEvents: UIControlEventTouchUpInside ];
[button setImage:nil forState:UIControlStateNormal];
[self.scrollview addSubview:button];
}
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。