九宮格
NSInteger count = self.subviews.count;
CGFloat padding = 10;
NSInteger totalCol = 3;
CGFloat x = 0;
CGFloat y = 0;
CGFloat wh = (self.bounds.size.width - (totalCol + 1) * padding) / totalCol;
;
NSInteger col = 0;
NSInteger row = 0;
for (NSInteger i = 0; i < count; i ++) {
col = i % totalCol;
x = col * (padding + wh);
row = i / totalCol;
y = row * (padding + wh);
UIImageView *imageV = self.subviews[i];
imageV.frame= CGRectMake(x, y, wh, wh);
}
分頁(yè)公式
NSInteger totalCol = (count + rowMaxTotal - 1) / rowMaxTotal; //總共行數(shù)
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者