Обобщая немного ответ Джонатана, вот интерфейс категории, который вы можете просто вставить в соответствующие файлы в вашем проекте XCode:
@interface NSTextView (FrameworkAdditions)
- (IBAction)decrementFontSize:(id)sender;
- (IBAction)incrementFontSize:(id)sender;
@end
И соответствующая реализация:
@implementation NSTextView (FrameworkAdditions)
- (void)changeFontSize:(CGFloat)delta;
{
NSFontManager * fontManager = [NSFontManager sharedFontManager];
NSTextStorage * textStorage = [self textStorage];
[textStorage beginEditing];
[textStorage enumerateAttribute:NSFontAttributeName
inRange:NSMakeRange(0, [textStorage length])
options:0
usingBlock:^(id value,
NSRange range,
BOOL * stop)
{
NSFont * font = value;
font = [fontManager convertFont:font
toSize:[font pointSize] + delta];
if (font != nil) {
[textStorage removeAttribute:NSFontAttributeName
range:range];
[textStorage addAttribute:NSFontAttributeName
value:font
range:range];
}
}];
[textStorage endEditing];
[self didChangeText];
}
- (IBAction)decrementFontSize:(id)sender;
{
[self changeFontSize:-1.0];
}
- (IBAction)incrementFontSize:(id)sender;
{
[self changeFontSize:1.0];
}
@end