测试已测试 | ✗ |
语言语言 | SwiftSwift |
许可证 | MIT |
发布最后发布 | 2017年12月 |
SwiftSwift 版本 | 3.0 |
SPM支持 SPM | ✗ |
由 SYParallaxScrollViewTrunk 维护。
SYParallaxViewItem
对象。let view = UIView(...)
let item = SYParallaxViewItem(view: view,
originOffset: CGPoint(x: 150, y: 80),
acceleration: SYParallaxAcceleration.invariable(CGPoint(x: 1, y: 1)),
progress: { (parallaxView, view) in
//...
}
)
如果您愿意,您还可以定义一个动态加速度。
let dynamicAcceleration = SYParallaxAcceleration.variable { (parallaxView, view) -> CGPoint in
let progressRatio = (parallaxView.contentSize.width - 3 * parallaxView.contentOffset.x) / parallaxView.contentSize.width
return CGPoint(x: 0.65 * progressRatio, y: 0.65 * (1 - progressRatio))
}
let view = UIView(...)
let item = SYParallaxViewItem(view: view,
originOffset: CGPoint(x: 150, y: 80),
acceleration: dynamicAcceleration,
progress: { (parallaxView, view) in
//...
}
)
let parallaxView = SYParallaxScrollViewBuilder.setOption { (option) in
option.frame = CGRect(x: 0, y: 100, width: view.frame.size.width, height: view.frame.size.height - 100)
option.parallaxViewItems = [item] // You can add more items.
option.isPagingEnabled = false
}.build()
parallaxView.delegate = self //Optional
Minimum iOS Target : iOS 8.0
SYParallaxScrollView 通过 CocoaPods 可用。要安装它,只需将以下行添加到您的 Podfile 中即可
pod 'SYParallaxScrollView'
SYParallaxScrollView 在 MIT 许可下可用。有关更多信息,请参阅 LICENSE 文件。