Closed skuske closed 4 years ago
/** accessory view for above picker view. default is nil */
@property (nonatomic, strong) UIView *pickerHeaderView;
/** accessory view below picker view. default is nil */
@property (nonatomic, strong) UIView *pickerFooterView;
UIView *headerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 36)];
headerView.backgroundColor = [[UIColor grayColor] colorWithAlphaComponent:0.1f];
NSArray *unitArr = @[@"年", @"月", @"日"];
for (NSInteger i = 0; i < unitArr.count; i++) {
CGFloat width = SCREEN_WIDTH / unitArr.count;
CGFloat orginX = i * (SCREEN_WIDTH / unitArr.count);
UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(orginX, 0, width, 36)];
label.backgroundColor = [UIColor clearColor];
label.textAlignment = NSTextAlignmentCenter;
label.font = [UIFont systemFontOfSize:16.0f];
label.textColor = [UIColor darkGrayColor];
label.text = unitArr[i];
[headerView addSubview:label];
}
datePickerView.pickerHeaderView = headerView;
@91renb
Many thanks!
I noticed the
pickerStyleWithDateUnitOnTop
for date pickers, and I was wondering if there is any way to create custom unit strings on top for all other picker styles, too. That would make it easy to create explanations for the displayed picker arrays. Best would be if there was also a way to set font size and style for the unit labels.Many thanks for this brilliant component! :o)