快速划分分栏控制器上的item(自定义)

         

 

1. CGRect screenRect = [[UIScreen mainScreen] bounds];//获取整体屏幕的宽度

2.  NSInteger itemCount = [self.naviArray count]; //获取item的个数

 

3.float width = screenRect.size.width/itemCount;//平分这个宽度

 4. float tabMarginx = (width - TabItemImageWidth)*0.5;//TabItemImageWidth是每个item中图片的宽度,通过这句获取距离x的距离

5.在for循环里面这样设置

UIImageView *itemBg  = [[UIImageView alloc] initWithFrame:CGRectMake(tabMarginx+width * i, TabSideMarginY, TabItemImageWidth, TabItemImageHeight)];

 

posted @ 2015-12-08 10:28  蜗牛d  阅读(176)  评论(0)    收藏  举报