I am using a UITextView
that gets its attributedText
set from an rtf file to show T&C, Privacy pages etc.
The rtf file is already formatted so it contains differently sized titles, paragraphs etc. Is there a way of saying something like "make the font size everywhere 3pt larger"? Surely I'm not going to specify a character range for every sentence and title in the file and manually set the font size.
Here's what I'm doing:
@implementation RTFViewController
- (instancetype)initWithRTFURL:(NSURL *)url title:(NSString *)title {
self = [super init];
if (self) {
self.navigationItem.title = title;
self.text = [[NSAttributedString alloc] initWithFileURL:url
options:@{NSDocumentTypeDocumentAttribute:NSRTFTextDocumentType}
documentAttributes:nil
error:nil];
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
self.textView = [UITextView newAutoLayoutView];
self.textView.editable = NO;
self.textView.textContainerInset = UIEdgeInsetsMake(20.0f, 20.0f, 20.0f, 20.0f);
self.textView.dataDetectorTypes = UIDataDetectorTypeAll;
self.textView.attributedText = self.text;
[self.view addSubview:self.textView];
}
@end
EDIT
I'm able to achieve what I want by looping through the string and setting the font to a multiple of the original font size, as described here: https://stackoverflow.com/a/19387401/2026098
Would still be nice to have a more concise solution, one that doesn't involve looking at every single character in turn.