我尝试使用以下代码更改UIPicker中元素的字体和大小:
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
{
UILabel *pickerViewLabel = (id)view;
if (!pickerViewLabel) {
pickerViewLabel= [[UILabel alloc] initWithFrame:CGRectMake(0.0f, 0.0f, [pickerView rowSizeForComponent:component].width - 10.0f, [pickerView rowSizeForComponent:component].height)];
}
pickerViewLabel.backgroundColor = [UIColor clearColor];
pickerViewLabel.text = _startTimeArray[row];
pickerViewLabel.font = [UIFont fontWithName:@"Helvetica Neue Regular" size:(22)];
return pickerViewLabel;
}
我能够改变字体的类型,但无论我输入什么值,大小都保持不变。有谁知道为什么字体大小没有改变?谢谢!