Soft scroll animation NSScrollView scrollToPoint:

前端 未结 5 1203
旧巷少年郎
旧巷少年郎 2021-02-13 23:53

I want to create soft animation between transitions in simply UI:

\"first

5条回答
  •  别那么骄傲
    2021-02-14 00:24

    Swift 4 code of this answer

    func scroll(toPoint: NSPoint, animationDuration: Double) {
        NSAnimationContext.beginGrouping()
        NSAnimationContext.current.duration = animationDuration
        let clipView = scrollView.contentView
        clipView.animator().setBoundsOrigin(toPoint)
        scrollView.reflectScrolledClipView(scrollView.contentView)
        NSAnimationContext.endGrouping()
    }
    

提交回复
热议问题