在 NSImage 下绘制阴影
目前,我正在自定义 NSCell 中绘制 NSImage,如下所示:
- (void)drawInteriorWithFrame:(NSRect)theCellFrame inView:(NSView *)theControlView {
// roundedCornerImage creates a new NSImage with rounded corners, rather than clipping.
[[anIcon roundedCornerImage:5] drawInRect:anIconBox fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0];
}
很简单,我想知道如何在其下方绘制图像。在 iPhone 上,我将使用以下方法来完成此操作:CGContextSetShadow (currentContext, CGSizeMake(1, -1), 2)
;就在绘制 UIImage 之前,但我不熟悉如何在 Mac 上执行此操作。
任何指点都会很棒。
Currently I'm drawing an NSImage in a custom NSCell like so:
- (void)drawInteriorWithFrame:(NSRect)theCellFrame inView:(NSView *)theControlView {
// roundedCornerImage creates a new NSImage with rounded corners, rather than clipping.
[[anIcon roundedCornerImage:5] drawInRect:anIconBox fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0];
}
Very simply I'm wondering how to draw an image underneath it. On the iPhone, I would do this by using: CGContextSetShadow (currentContext, CGSizeMake(1, -1), 2)
; just before drawing the UIImage, but I'm unfamiliar with how to do it on the Mac.
Any pointers would be great.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看
NSShadow
类。CGContextSetShadow
也存在于 Mac 上,但获取上下文本身稍微困难一些。Look into the
NSShadow
class.CGContextSetShadow
also exists on the Mac, but it's slightly more difficult to get your hands on the context itself.