我可以使用类似的东西(UI 而不是 NS)写入 iOS。但在 OSX 上失败了?
NSString *sText = @"Hello";
[sText drawInRect:CGRectMake(x, y, 150, 20) withFont:[NSFont boldSystemFontOfSize:fSize]];
// No visible @interface for 'NSString' declares the selector 'drawInRect:withFont:'
最佳答案
您需要在 OS X 上使用 NSAttributedString
属性:
NSString *sText = @"Hello";
[sText drawInRect:CGRectMake(x, y, 150, 20) withAttributes: @{ NSFontAttributeName :
[NSFont boldSystemFontOfSize:fSize] }];
关于macos - 如何将NSString写入NSView?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35323407/