自定义 NSPopUpButtonCell drawImage:withFrame:inView 未被调用

发布于 2024-08-20 07:29:43 字数 232 浏览 10 评论 0原文

我有一个自定义 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

仄言 2024-08-27 07:29:43

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文