Resise NSWindow,不显示调整大小按钮

问题描述:

我想有一个可以调整大小但不显示左上角的小绿色调整大小按钮的NSWindow。这是可能吗?

I would like to have an NSWindow that is resizable but without showing the little green resize button in the top left corner. Is this possible?

创建NSWindow的自定义子类并重写standardWindowButton:forStyleMask:类方法

Create custom subclass of NSWindow and override "standardWindowButton: forStyleMask:" class method

@interface CustomWindow : NSWindow
@end

@implementation CustomWindow

+ (NSButton *)standardWindowButton:(NSWindowButton)b forStyleMask:(NSUInteger)styleMask
{
  NSButton *button = [super standardWindowButton:b forStyleMask:styleMask];
  if (b == NSWindowZoomButton) {
    button.hidden = YES;
  }
  return button;
}