开发者

Custom ScrollView, How to make NSView setFrame: faster?

I am开发者_如何转开发 making my own ScrollView. here is the code i use for scrolling with mouse wheel or touchpad but it doesn't work flawless. it lags a bit.

- (void) scrollWheel:(NSEvent *)theEvent
{
    NSRect rect = [contentView frame];
    rect.origin.x += [theEvent deltaX];
    rect.origin.y += [theEvent deltaY];

    [contentView setFrame:rect];
}

when i do the same with layers (for test) it works much better.

[CATransaction setDisableActions:YES];
[CATransaction begin];
[contentView layer].frame = newRect;
[CATransaction commit];

how to make setFrame work flawless?


I was looking hard, on how it is done by apple in NSScrollView. and the answer is that they make high performance drawing - only the changed parts, not the whole view as it is usually done.

After that i decided to customize the standard scrollView and standard scrollers.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜