码迷,mamicode.com
首页 > 移动开发 > 详细

iOS九宫格布局

时间:2015-04-14 13:01:30      阅读:186      评论:0      收藏:0      [点我收藏+]

标签:ios   ios开发   uibutton   布局   

  

        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:) forControlEventsUIControlEventTouchUpInside ];

            [button setImage:nil forState:UIControlStateNormal];

            [self.scrollview addSubview:button];

        }

iOS九宫格布局

标签:ios   ios开发   uibutton   布局   

原文地址:http://blog.csdn.net/yangchen9931/article/details/45039679

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!