当前位置 : 主页 > 编程语言 > python >

UIPickerView控件中自定义显示的字体大小及样式

来源:互联网 收集:自由互联 发布时间:2023-03-22
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view{ UILabel* pickerLabel = (UILabel*)view; if (!pickerLabel){ pickerLabel = [[UILabel alloc] init]; // Set

- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view{ UILabel* pickerLabel = (UILabel*)view; if (!pickerLabel){ pickerLabel = [[UILabel alloc] init]; // Setup label properties - frame, font, colors etc //adjustsFontSizeToFitWidth property to YES pickerLabel.minimumFontSize = 8.; pickerLabel.adjustsFontSizeToFitWidth = YES; [pickerLabel setTextAlignment:UITextAlignmentLeft]; [pickerLabel setBackgroundColor:[UIColor clearColor]]; [pickerLabel setFont:[UIFont boldSystemFontOfSize:15]]; } // Fill the label text here pickerLabel.text=[self pickerView:pickerView titleForRow:row forComponent:component]; return pickerLabel; }
上一篇:Service 与 Thread 的区别
下一篇:没有了
网友评论