类似时间选择器的PickerView,可以自定义显示内容,创建方法:
#pragma mark - 视图懒加载
-(UIPickerView *)catePickerView{
if (!_catePickerView) {
_catePickerView = [[UIPickerView alloc] init];
_catePickerView.delegate =self;
_catePickerView.backgroundColor = [UIColor whiteColor];
_catePickerView.layer.cornerRadius = 50;
_catePickerView.clipsToBounds = YES;
}
return _catePickerView;
}
代理方法返回自定义视图:
-(UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view{
UIView *custView = [[UIView alloc] initForAutoLayout];
if (pickerView==_catePickerView) {
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(30, 10, 100, 40)];
[custView addSubview:label];
label.textAlignment = NSTextAlignmentCenter;
label.text = _cateArr[row];
label.font = [UIFont systemFontOfSize:24];
}
return custView;
}