Skip to content

uicollectview均分的问题 #135

Open

Description

@wzj583585700
UIView *root = [[UIView alloc] initWithFrame:self.bounds];
root.backgroundColor = [UIColor yellowColor];
[self.contentView addSubview:root];    

MyBaseLayout *root = [[MyBaseLayout alloc] initWithFrame:self.bounds];
root.backgroundColor = [UIColor yellowColor];
[self.contentView addSubview:root];
第一个view的宽度是32.8333  第二个直接就是33,这差别有点大啊

Activity

  1. youngsoft commented on Nov 12, 2020

    @youngsoft
    Owner

    MyLayout内部对尺寸进行了优化处理,也就是保证了设置的逻辑尺寸会有效的转化为物理像素。就如32.8333这个逻辑点经过特殊处理后就形成了33这个实际有效的值。另外看您代码中用的是一个MyBaseLayout。理论中我们是不支持在实际代码中直接使用MyBaseLayout的,而是其派生类。

  2. wzj583585700 commented on Nov 17, 2020

    @wzj583585700
    Author

    flowLayout.itemSize = CGSizeMake((screenW-20) / 12, 35); UICollectionView 这样写的时候,个别cell之间会有间隙,但是用frame布局的话,就没有这个问题,

  3. youngsoft commented on Nov 17, 2020

    @youngsoft
    Owner

    具体明细请加 qq 群:178573773 进行详细讨论吧。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions