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

UIPickView 有默认间距, 库中计算column的宽度不合适 #318

Open
hupengfei-hinterstellar opened this issue Jul 29, 2024 · 0 comments

Comments

@hupengfei-hinterstellar
// 设置列宽
- (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component {
    NSInteger columnCount = [self numberOfComponentsInPickerView:pickerView];
    CGFloat columnWidth = self.pickerView.bounds.size.width / columnCount;
    if (self.pickerStyle.columnWidth > 0 && self.pickerStyle.columnWidth <= columnWidth) {
        return self.pickerStyle.columnWidth;
    }
    return columnWidth;
}

单单宽度除以列数会导致长度超出屏幕, 但我没找到系统中这个关于间距的具体值.

若不实现 宽度 的代理方法 则系统会自动调整以适应屏幕,不过这样就失去了灵活性, 所以除了自己给columnWidth设定一个近似值外,还有什么更好的方式吗?

截图使用 375宽 iOS12 机型
image

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

1 participant