如何更改字体系列&;iOS中文本视图的样式?
我想更改如何更改字体系列&;iOS中文本视图的样式?,ios,objective-c,Ios,Objective C,我想更改UITextView的字体样式和字体系列。实际上,我将从选择器中选择字体系列,然后更改UITextView的字体系列。请告诉我如何操作?尝试在选择器中显示字体系列的名称 - (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view{ UILabel* labelFontName
UITextView
的字体样式和字体系列。实际上,我将从选择器中选择字体系列,然后更改UITextView
的字体系列。请告诉我如何操作?尝试在选择器中显示字体系列的名称
- (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];
在这个假设中,我提交了我的答案,如果这里有任何疑问,请自定义您自己
-(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];
}
对于选取器显示选取器选择代码我还没有为字体编写任何代码。我需要编写创建选取器的代码,然后使字体数据和选取器中的选定字体在文本视图中应用选定字体,如果遇到任何问题,则显示代码。我不知道为更改字体系列编写什么代码UITEXTVIEW这是worng bro,我们如何知道拾取表中包含的数据我可以只更改字体吗family@deepakkumar--如果您知道中的字体系列已经添加了您的seif,那么我的意思是我不想更改字体大小,那么在这种情况下该怎么办@Anbu@deepakkumar-[yourTextView setFont:[UIFont fontWithName:@“addyourFontName”大小:18.0f]];//只需更改字体名称,无需更改字体大小哦,天哪……它工作起来很神奇。请告诉我是什么问题?