#define PriceLabelWidth 100*SCREEN_RATIO // 价格label的宽
#define PriceLabelHeight 30*SCREEN_RATIO // 价格label的高
#define TransverseSpace (SCREEN_WIDTH-3*100*SCREEN_RATIO)/4 //横间距
#define HeightSpace 2*SCREEN_RATIO // 竖间距
for (int i = 0; i< greadPriceArr.count; i++)
{
这里 M 需要换成每一行控件 的个数
NSInteger lie = i % (M);//余数 为 0 1 2 (控制 X)
NSInteger row = i / M ; // 商 为 0 1 2 3 4 5 6 7 8 ... (控制Y)
UILabel*priceLabel=[[UILabel alloc]init];
priceLabel.frame=CGRectMake(lie*(PriceLabelWidth+TransverseSpace)+TransverseSpace, row*(HeightSpace+PriceLabelHeight+HeightSpace+CountLabelHeight)+HeightSpace, PriceLabelWidth, PriceLabelHeight);
[self addSubview:priceLabel];
}
网友评论