How to Animate scrollpoint?

You can create a subclass of NSAnimation to do this. I've created one as part of an open source project of mine (with public domain license).

You can find it here: https://github.com/abhibeckert/Dux/blob/master/Dux/DuxScrollViewAnimation.m (note: this project has ARC enabled. If you're not using ARC you will need to update as appropriate).

Example:

[DuxScrollViewAnimation animatedScrollToPoint:NSMakePoint(x,y) inScrollView:self.enclosingScrollView];

In my app, I set the clipView's boundsOrigin using its animator:

[NSAnimationContext beginGrouping];
NSClipView* clipView = [[myView enclosingScrollView] contentView];
NSPoint newOrigin = [clipView bounds].origin;
newOrigin.x = my_new_origin.x;
[[clipView animator] setBoundsOrigin:newOrigin];
[NSAnimationContext endGrouping];

Tags:

Cocoa

Scroll