用一点点狩猎和拼凑的东西来计算这个.
为要在动画中更改的约束创建IBOutlet.在这种情况下,请为每个滚动视图使用前导约束.
@IBOutlet weak var ScrollView1LeadingConstraint: NSLayoutConstraint!
@IBOutlet weak var ScrollView2LeadingConstraint: NSLayoutConstraint!
Run Code Online (Sandbox Code Playgroud)
然后,使用以下内容:
NSAnimationContext.runAnimationGroup({ (context) -> Void in
context.duration = //length of the animation time in seconds
self. ScrollView1LeadingConstraint.animator().constant = //negative width of scroll view
self.ScrollView2LeadingConstraint.animator().constant = 0
}, completionHandler: { () -> Void in
//insert any completion code here
})
Run Code Online (Sandbox Code Playgroud)
这将为左侧框架中的第一个滚动视图设置动画,并将第二个滚动视图移动到其以前的位置.
| 归档时间: |
|
| 查看次数: |
1441 次 |
| 最近记录: |