自定义 NSScrollers 具有来自核心动画的奇怪效果
我正在制作自定义 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,这个问题就会消失。
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看来问题的答案似乎是调用:
[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? :(
您可能已经知道这一点,但就您而言,以下内容应该可以解决您的绘图问题:
You probably found this out by know, but in your case, the following piece should solve your drawing issue: