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

addPickerToView:样式错乱 #309

Closed
taojeff opened this issue May 27, 2024 · 5 comments
Closed

addPickerToView:样式错乱 #309

taojeff opened this issue May 27, 2024 · 5 comments

Comments

@taojeff
Copy link

taojeff commented May 27, 2024

`// 3.创建选择器容器视图
UIView *containerView = [[UIView alloc]initWithFrame:CGRectMake(30, 170, self.view.frame.size.width - 60, 200)];
containerView.backgroundColor = UIColor.redColor;
containerView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[self.view addSubview:containerView];

// 4.创建日期选择器
BRDatePickerView *datePickerView = [[BRDatePickerView alloc]init];
datePickerView.pickerMode = BRDatePickerModeDateAndTime;
datePickerView.maxDate = [NSDate date];
datePickerView.isAutoSelect = YES;
datePickerView.showUnitType = BRShowUnitTypeOnlyCenter;
datePickerView.resultBlock = ^(NSDate *selectDate, NSString *selectValue) {
    if (self.timeType == BRTimeTypeBeginTime) {
        self.beginSelectDate = selectDate;
        self.beginTimeTF.text = selectValue;
    } else if (self.timeType == BRTimeTypeEndTime) {
        self.endSelectDate = selectDate;
        self.endTimeTF.text = selectValue;
    }
};

// 自定义选择器主题样式
BRPickerStyle *customStyle = [[BRPickerStyle alloc]init];
customStyle.pickerColor = containerView.backgroundColor;
datePickerView.pickerStyle = customStyle;、

// 添加选择器到容器视图
[datePickerView addPickerToView:containerView];`
image 我将pickview放在view上后发现样式布局错了
@agiapp agiapp closed this as completed in 4c34b7c May 28, 2024
@agiapp
Copy link
Owner

agiapp commented May 28, 2024

已修复,请更新到最新版本进行使用

@taojeff
Copy link
Author

taojeff commented May 28, 2024

已修复,请更新到最新版本进行使用

多谢,博主,如果有时间的话是否可以更新一个新的样式“年月日周、时、分、秒”这样四列滚轮样式

@agiapp
Copy link
Owner

agiapp commented May 28, 2024

针对需要显示星期的场景,可以配合设置 datePickerView.showWeek = YES; 来达到类似的效果

代码

BRDatePickerView *datePickerView = [[BRDatePickerView alloc]init];
datePickerView.pickerMode = BRDatePickerModeYMDHMS;
datePickerView.showWeek = YES;
datePickerView.resultBlock = ^(NSDate *selectDate, NSString *selectValue) {
    
};
[datePickerView show];

效果

image

@taojeff
Copy link
Author

taojeff commented May 28, 2024 via email

@agiapp
Copy link
Owner

agiapp commented May 28, 2024

有设计稿吗,一般很少有这种使用场景。特殊场景要么使用多个 BRDatePickerView 组件 进行组合使用,或者像这种特殊效果也可以使用 BRStringPickerView组件自定义数据源来实现。

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