我想改变字体样式& UITextView
的家人。实际上,我会从选择器中选择字体系列,然后更改UITextView
的字体系列。请告诉我该怎么做?
答案 0 :(得分:1)
在这个假设中,我提交了我的答案,如果有任何疑问,请自定义其他
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:
(NSInteger)row inComponent:(NSInteger)component{
// here you can get index for selected Row
[yourTextView setText:[pickerArray objectAtIndex:row]];
[yourTextView setFont:[UIFont fontWithName:@"Helvetica Neue" size:18.0f]];
yourTextView.textColor = [UIColor whiteColor];
}
for picker tutorial
答案 1 :(得分:0)
尝试此选项以在选择器中显示系列字体名称
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view{
UILabel* labelFontName = (UILabel*)view;
if (!labelFontName ){
labelFontName = [[UILabel alloc] init];
labelFontName .adjustsFontSizeToFitWidth = YES;
labelFontName .TextAlignment = NSTextAlignmentCenter;
labelFontName .font = [UIFont fontWithName:@"Arial" size:18];
}
NSString *stringForTitle= [NSString stringWithFormat:@"%@", [arrayOfYourPickerElements objectAtIndex:row]];// Fill the label text here
labelFontName .text = stringForTitle;
return labelFontName ;
}
选择fontName后:
yourTextView.font = [UIFont fontWithName:label size:17];