Soft scroll animation NSScrollView scrollToPoint:

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

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

\"first

5条回答
  •  名媛妹妹
    2021-02-14 00:46

    Here is a Swift 4 extension version of Andrew's answer

    extension NSScrollView {
        func scroll(to point: NSPoint, animationDuration: Double) {
            NSAnimationContext.beginGrouping()
            NSAnimationContext.current.duration = animationDuration
            contentView.animator().setBoundsOrigin(point)
            reflectScrolledClipView(contentView)
            NSAnimationContext.endGrouping()
        }
    }
    

提交回复
热议问题