美文网首页
图书的摆放

图书的摆放

作者: 再也不要见 | 来源:发表于2016-12-27 18:15 被阅读0次

    一、

    e.g.:

    1:1 1:2 1:3 2排 9张图片

    NSInteger count = 4;//代表图片的张数

    CGFloat viewWH = self.view.bounds.size.width;

    NSInteger row = count / 3;

    CGFloat imageWH = viewWH / (row ? 3 : count);

    UIView * backView = [[UIView alloc] initWithFrame:CGRectMake(0, 100, viewWH, 0)];

    backView.backgroundColor = [UIColor blackColor];

    [self.view addSubview:backView];

    UIView * view;

    for (NSInteger i = 0; i < count; i++) {

    CGFloat viewX = i % 3 * imageWH;

    CGFloat viewY = i / 3 * imageWH;

    view = [[UIView alloc] initWithFrame:CGRectMake(viewX, viewY, imageWH, imageWH)];

    view.backgroundColor = [UIColor colorWithRed:arc4random()%256 / 255.0 green:arc4random()%256 / 255.0 blue:arc4random()%256 / 255.0 alpha:1];

    [backView addSubview:view];

    }

    backView.frame = CGRectMake(0, 100, viewWH, view.frame.origin.y + view.frame.size.height);

    相关文章

      网友评论

          本文标题:图书的摆放

          本文链接:https://www.haomeiwen.com/subject/lejevttx.html