agiapp / BRPickerView

BRPickerView 封装的是iOS中常用的选择器组件,主要包括:日期选择器(支持年月日、年月等15种日期样式选择,支持设置星期、至今等)、地址选择器(支持省市区、省市、省三种地区选择)、自定义字符串选择器(支持单列、多列、二级联动、三级联动选择)。支持自定义主题样式,适配深色模式,支持将选择器组件添加到指定容器视图。
https://github.com/agiapp/BRPickerView
MIT License
2.55k stars 442 forks source link

间距异常 #276

Closed CH305426 closed 5 months ago

CH305426 commented 2 years ago

你好, 我使用的是时间选择器

BRDatePickerView *datePickerView = [[BRDatePickerView alloc]init];
datePickerView.pickerMode = BRDatePickerModeHM;
datePickerView.title = @"设置时间提醒";
datePickerView.selectDate = ({
    NSString *text = self.timeLab.text;
    NSArray *array = [text componentsSeparatedByString:@":"];
    NSDate *sss = [NSDate br_setHour:[array[0] integerValue]  minute:[array[1] integerValue]];
    sss;
});
datePickerView.isAutoSelect = NO;
datePickerView.showUnitType = BRShowUnitTypeOnlyCenter;
datePickerView.pickerStyle = ({
    //自定义样式
    BRPickerStyle *style = [[BRPickerStyle alloc] init];
    style.pickerColor = BR_RGB_HEX(0xFFFFFF, 1.0f);
    style.separatorColor = [UIColor clearColor];
    style.topCornerRadius = 12;

    /** 设置 titleBarView*/
    style.hiddenTitleLine = NO;
    style.titleLineColor = UIColorHex(#F6F6F8);
    style.titleBarHeight = 60;

    /** 设置 titleLabel */
    style.titleTextColor = UIColorHex(#333333);
    style.titleTextFont = [UIFont systemFontOfSize:17 weight:UIFontWeightMedium];
    style.titleLabelFrame = CGRectMake(100, 0, kScreenWidth- 200, 60);

    /** 设置 doneBtn */
    style.doneTextColor = UIColorHex(#51B7DC);
    style.doneTextFont = [UIFont systemFontOfSize:15 weight:UIFontWeightMedium];
    style.doneBtnFrame = CGRectMake(kScreenWidth- 80, 0, 80, 60);

    /** 设置 cancelBtn */
    style.cancelTextColor = UIColorHex(#666666);
    style.cancelTextFont = [UIFont systemFontOfSize:15 weight:UIFontWeightMedium];
    style.cancelBtnFrame = CGRectMake(0, 0, 80, 60);

    style.paddingBottom = kSafeArea_Bottom;
    style.rowHeight = 60;
    style.pickerHeight = 286;

    style.selectRowColor = UIColorHex(#F8F9FC);

    style.pickerTextColor = UIColorHex(#4C5362);
    style.pickerTextFont = [UIFont fontWithName:DIN_ALTERNATE size:22];

    style.dateUnitTextFont = [UIFont systemFontOfSize:14];
    style.dateUnitTextColor = UIColorHex(#4C5362);

    style;
});

datePickerView.resultBlock = ^(NSDate *selectDate, NSString *selectValue) {
    NSLog(@"选择的值:%@", selectValue);
};
[datePickerView show];

碰到的问题是 ,在年月日上 pickerView看着挺好的, 但是在时分上有间距, 不知道为啥了

lQDPJxZpYoESYSfNBQDNAlCwb7tjsQnGsdcCrbqOO0AHAA_592_1280 jpg_720x720g

lQDPJxZpYoGq-SrNBQDNAlCwFGfT4gnLN3MCrbqPp8AHAA_592_1280 jpg_720x720g

agiapp commented 2 years ago

是iOS哪个系统,我这边在模拟器上(iOS14、iOS15)测试没有问题。使用的样例代码,效果如下: image

另外显示效果有异常,也可以使用下面这两个属性,对单位Label的位置进行微调

/** 设置日期选择器单位 label 的水平方向偏移量 */
@property (nonatomic, assign) CGFloat dateUnitOffsetX;

/** 设置日期选择器单位 label 的竖直方向偏移量 */
@property (nonatomic, assign) CGFloat dateUnitOffsetY;