Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uicollectview均分的问题 #135

Open
wzj583585700 opened this issue Nov 11, 2020 · 3 comments
Open

uicollectview均分的问题 #135

wzj583585700 opened this issue Nov 11, 2020 · 3 comments

Comments

@wzj583585700
Copy link

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,这差别有点大啊
@youngsoft
Copy link
Owner

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

@wzj583585700
Copy link
Author

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

@youngsoft
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants