我有一个UITextView
来展示一些文字,textView是用代码创建的:
UITextView *textView = [[UITextView alloc] initWithFrame:labelFrame];
[textView setFont:[UIFont systemFontOfSize:prefObj.Setting_Font_Size]];
textView = NO;
textView = NSTextAlignmentJustified;
textView = [UIColor clearColor];
textView = UIViewAutoresizingFlexibleHeight;
[self addSubview:textView];
prefObj.Setting_Font_Size
默认值为16 ,,用户可以更改设置面板中的字体,,,一旦用户选择了我希望反映到UITextView
的新尺寸, ,我用它来更新字体大小:
-(void)updateFontSize
{
[textView setFont:[UIFont systemFontOfSize:prefObj.Setting_Font_Size]];
}
我确信prefObj.Setting_Font_Size
的值会保留新选择的尺寸,但是文字保持不变,但我怎么能解决这个问题?
答案 0 :(得分:0)
解决方案很简单,但我忘了UITextView
是在UIView
类中创建的,
所以我将UITextView的实例作为UIView
类中的属性,并更改我创建UIView
的字体大小:
UIView子类:
@interface TextToShow : UIView
@property (nonatomic, strong) UITextView *textView;
@end
UIViewController
中的:
TextToShow *TextToShowView = [[TextToShow alloc] initWithFrame:Frame];
[TextToShowView.textView setFont:[UIFont systemFontOfSize:prefObj.Setting_Font_Size]];