0

我要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将保持新选择的大小,,但文本保持不变,没有任何变化,,我该如何解决这个问题?

4

1 回答 1

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]];
于 2013-03-14T15:23:57.440 回答