如何反转NSScrollView滚动方向?

时间:2016-08-17 08:35:54

标签: macos cocoa nsscrollview

我有NSScrollView我通过CATransform3DMakeScale(1.0f,-1.0f,1.0f)进行转换,然后它开始向错误的方向滚动,现在我需要根据Y ax滚动到相反的方向

更新

通过继承NSScrollView找到解决方案:

- (void)scrollWheel:(NSEvent *)theEvent
{
    int scrollingDeltaY = -[theEvent deltaY];
    CGEventRef cgEvent = CGEventCreateCopy(theEvent.CGEvent);

    CGEventSetIntegerValueField(cgEvent, kCGScrollWheelEventDeltaAxis1, scrollingDeltaY);

    NSEvent *newEvent = [NSEvent eventWithCGEvent:cgEvent];
    CFRelease(cgEvent);

    [super scrollWheel:newEvent];
}

0 个答案:

没有答案