ios九宫格实现:
如图:
//列数
int totalloc=3;
//有多少个需要展示的imageview
int count=12;
//imageview的宽高
CGFloat imageviewH=80;
CGFloat imageviewW=80;
//间距
CGFloat margin=(self.view.frame.size.width-totalloc*imageviewW)/(totalloc+1);
for (int i=0; i<count; i++) {
//行号
int row = i/totalloc;
//列号
int loc=i%totalloc;
//求出第i个imageview的x和y坐标
CGFloat imageviewX=margin+(margin + imageviewW)*loc;
CGFloat imageviewY=margin+(margin + imageviewH)*row;
}