Objective c NSPopUpButtonCell子类以标准外观设置关闭动画
我创建了一个NSPopUpButtonCell子类来定制它的外观 当从弹出窗口中选择一个菜单项时,它将以OS X 10.10上的标准弹出窗口外观为选择设置动画 我希望它与我的自定义外观动画 自定义弹出窗口 设置所选内容的动画Objective c NSPopUpButtonCell子类以标准外观设置关闭动画,objective-c,macos,cocoa,osx-yosemite,nspopupbuttoncell,Objective C,Macos,Cocoa,Osx Yosemite,Nspopupbuttoncell,我创建了一个NSPopUpButtonCell子类来定制它的外观 当从弹出窗口中选择一个菜单项时,它将以OS X 10.10上的标准弹出窗口外观为选择设置动画 我希望它与我的自定义外观动画 自定义弹出窗口 设置所选内容的动画 - (void)drawBezelWithFrame:(NSRect)frame inView:(NSView *)controlView { [[NSGraphicsContext currentContext] saveGraphicsState];
- (void)drawBezelWithFrame:(NSRect)frame inView:(NSView *)controlView {
[[NSGraphicsContext currentContext] saveGraphicsState];
NSBezierPath *rectanglePath = [NSBezierPath bezierPathWithRoundedRect:frame xRadius:5.0 yRadius:5.0];
[[NSColor colorWithWhite:0.7 alpha:1.0] setFill];
[rectanglePath fill];
float width = frame.size.width;
float height = frame.size.height;
NSBezierPath *path = [NSBezierPath bezierPath];
[path moveToPoint:CGPointMake(width - 5, height/2 - 2)];
[path lineToPoint:CGPointMake(width - 10, height/2 - 7)];
[path lineToPoint:CGPointMake(width - 15, height/2 - 2)];
[path moveToPoint:CGPointMake(width - 5, height/2 + 2)];
[path lineToPoint:CGPointMake(width - 10, height/2 + 7)];
[path lineToPoint:CGPointMake(width - 15, height/2 + 2)];
[path setLineWidth:2.0];
[[NSColor darkGrayColor] setStroke];
[path stroke];
[NSGraphicsContext restoreGraphicsState];
}
我的实施
- (void)drawBezelWithFrame:(NSRect)frame inView:(NSView *)controlView {
[[NSGraphicsContext currentContext] saveGraphicsState];
NSBezierPath *rectanglePath = [NSBezierPath bezierPathWithRoundedRect:frame xRadius:5.0 yRadius:5.0];
[[NSColor colorWithWhite:0.7 alpha:1.0] setFill];
[rectanglePath fill];
float width = frame.size.width;
float height = frame.size.height;
NSBezierPath *path = [NSBezierPath bezierPath];
[path moveToPoint:CGPointMake(width - 5, height/2 - 2)];
[path lineToPoint:CGPointMake(width - 10, height/2 - 7)];
[path lineToPoint:CGPointMake(width - 15, height/2 - 2)];
[path moveToPoint:CGPointMake(width - 5, height/2 + 2)];
[path lineToPoint:CGPointMake(width - 10, height/2 + 7)];
[path lineToPoint:CGPointMake(width - 15, height/2 + 2)];
[path setLineWidth:2.0];
[[NSColor darkGrayColor] setStroke];
[path stroke];
[NSGraphicsContext restoreGraphicsState];
}
必须在界面生成器上关闭“边界”属性 如果“边界”实际上处于关闭状态,则必须打开它,然后再关闭它 更好的方法是使用 -(void)DrawBorderAndBackgroundithFrame:(NSRect)查看中的单元格框架:(NSView*)控制视图