自定义 NSPopUpButtonCell drawImage:withFrame:inView 未被调用
我有一个自定义 NSPopUpButtonCell,我正在尝试覆盖 drawImage:withFrame:inView。奇怪的是,drawImage 方法从未被调用,但图像出现在屏幕上。我缺少什么?
我已检查以确保我的单元已正确安装 - 我收到了 drawWithFrame:inView:controlView 消息。
请注意,我正在尝试补偿仅图像的渐变样式按钮未正确居中其图像(它距离应有位置左侧 1 个像素)。
I have a custom NSPopUpButtonCell and I'm trying to override drawImage:withFrame:inView. Strangely, the drawImage method is never called, but the image appears on screen. What am I missing?
I've checked to make sure my cell is properly installed -- I am getting drawWithFrame:inView:controlView messages.
Note that I'm trying to compensate for an image only gradient-style button not properly centering it's image (it's 1 pixel to the left of where it should be).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
NSPopupButtonCell 继承自 NSMenuCell 和 NSMenuCell 有一个名为 drawImageWithFrame:inView: 这可能就是您正在寻找的。它还有其他几种绘图方法,因此请检查这些方法并查看正在调用哪一种。
NSPopupButtonCell inherits from NSMenuCell and NSMenuCell has a method called drawImageWithFrame:inView: which might be what you're looking for. It has several other drawing methods too so check those and see which one is being called.