自定义 NSScrollers 具有来自核心动画的奇怪效果

发布于 2024-09-10 12:08:24 字数 1019 浏览 5 评论 0原文

我正在制作自定义 NSScrollers 以在 NSScrollView 中使用。但是当 NSScroller 的任何超级视图启用核心动画时。我发现这个绘图问题非常麻烦。每当我滚动到滚动视图的角落时,滚动条就会被剪辑。但是,如果滚动条开始在角落绘制,则滚动条部分将停留在该角落。什么可能导致这个问题?我有太多代码无法在这里展示。但这是我的绘图代码:

NSRect knobRect = [self rectForPart:NSScrollerKnob];

NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:knobRect 
                                                     xRadius:CornerRadius 
                                                     yRadius:CornerRadius];

[path setLineWidth:2];
[[NSColor colorWithDeviceRed:0.114 green:0.114 blue:0.114 alpha:0.3] set];
[path fill];
[[NSColor colorWithDeviceWhite:1.0 
                         alpha:0.100] set];

    // Clip drawing to this path; draw nothing outwith the path. 
[path addClip];
[path stroke];

我已经尝试摆脱除填充之外的所有内容,但它不起作用。如果我在调用 setFloatValue 时在超级视图上调用 setNeedsDisplay:YES,这个问题就会消失。

剪辑问题 http://idkz.org/b814ee5c875c9f44cc2d1345e4489420

I am making custom NSScrollers for use in NSScrollView. But when any of the superviews of the NSScroller gets Core Animation enabled. I get this drawing issue that's a huge nuisance. Whenever i scroll into the corners of the scroll view the scrollers clip. But if a scroller starts out drawing in the corner, the scroller part stays in that corner. What could be causing this problem? I have too much code to show on here. But here is my drawing code:

NSRect knobRect = [self rectForPart:NSScrollerKnob];

NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:knobRect 
                                                     xRadius:CornerRadius 
                                                     yRadius:CornerRadius];

[path setLineWidth:2];
[[NSColor colorWithDeviceRed:0.114 green:0.114 blue:0.114 alpha:0.3] set];
[path fill];
[[NSColor colorWithDeviceWhite:1.0 
                         alpha:0.100] set];

    // Clip drawing to this path; draw nothing outwith the path. 
[path addClip];
[path stroke];

I already tried to get rid of everything except the fill but it didnt work. This issue goes away if I call setNeedsDisplay:YES on the super view when setFloatValue is called.

Clipping Issue http://idkz.org/b814ee5c875c9f44cc2d1345e4489420

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

鹿童谣 2024-09-17 12:08:24

看来问题的答案似乎是调用:
[self setArrowsPosition:NSScrollerArrowsNone];
它神奇地工作了:D

编辑,但是当我拖动滚动条时我得到了类似的效果。 :'( 有没有办法在不重新绘制滚动视图本身的情况下清除图形?:(

it seems that the answer to the problem seems to be to call:
[self setArrowsPosition:NSScrollerArrowsNone];
And it magically works :D

Edit, but I get a similar effect when I drag the scrollbar. :'( Is there anyway to clear the graphics without redrawing the scrollview itself? :(

陈年往事 2024-09-17 12:08:24

您可能已经知道这一点,但就您而言,以下内容应该可以解决您的绘图问题:

-(BOOL)isOpaque {
   return NO;
}

You probably found this out by know, but in your case, the following piece should solve your drawing issue:

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