测试已测试 | ✗ |
Lang语言 | SwiftSwift |
许可证 | MIT |
释放最新版本 | 2017年11月 |
SwiftSwift 版本 | 3.0 |
SPM支持 SPM | ✗ |
由 YoshimasaSakuragi 维护。
主要用于 iPad。
(例如:验收应用程序)
主视图由 'CoverView' 覆盖以显示标题或应用的一些用途。
为了有效利用 iPads 的高屏幕,操作主要通过上下滑动完成。
pod 'FluctuateViewController'
github "SakuragiYoshimasa/FluctuateViewController"
从 FluctuateViewController 继承子类。
如果您想使用自定义菜单视图或覆盖视图,继承 "MenuView" 和 "CoverView"。如果需要更多详细信息,请参阅 Demo 中的 "CustomMenuView" 和 "CustomCoverView"。
override func viewDidLoad() {
super.viewDidLoad()
//Setting propaties
fluctuateView.setPropaties(propaties: FluctuateViewPropaties(animationDuration: 0.4, menuHeight: 300, offsetOnNocontent: 300, offsetOnFixedContent: 200, fullCoveredOffset: 60))
}
// FluctuateViewDataSource
override func contentsCount() -> Int { return 3 }
override func fluctuateView(_ fluctuateView: FluctuateView, contentTitle index: Int) -> String {
return "\(index)"
}
override func fluctuateView(_ fluctuateView: FluctuateView, contentByIndex index: Int) -> UIViewController {
switch index {
case 0:
return UIStoryboard(name: "FixedVCDemoVC", bundle: nil).instantiateInitialViewController()!
case 1:
return UIStoryboard(name: "FixedScrollDemoVC", bundle: nil).instantiateInitialViewController()!
case 2:
return UIStoryboard(name: "FullScrollDemoVC", bundle: nil).instantiateInitialViewController()!
default:
return UIViewController()
}
}
override func fluctuateView(_ fluctuateView: FluctuateView, contentTypeByIndex index: Int) -> ContentViewType {
return index < 2 ? .fixed : .full
}
override func coverView() -> CoverView {
return CustomCoverView(frame: self.view.frame)
}
override func menuView() -> MenuView {
return CustomMenuView(frame: self.view.frame)
}
override func noContentView() -> UIViewController {
let vc = UIViewController()
vc.view.backgroundColor = UIColor.darkGray
return vc
}
// FluctuateViewDelegate
override func onStateChage(_ state: FluctuateViewState){
print("\(state)")
}
例如,您的自定义菜单视图需要继承 "MenuView",并按照您的具体情况覆盖 recreateMenuViewByContents 并调用 select(contentIndex: Int)。
class CustomMenuView : MenuView {
var buttons: [UIButton] = []
override func recreateMenuViewByContents(dataSource: FluctuateViewDataSource){
buttons.forEach({ $0.removeFromSuperview() })
buttons = []
for i in 1...dataSource.contentsCount() {
let button = UIButton(frame: CGRect(x: i * 120 + 100,y: 100, width: 100, height: 60))
button.backgroundColor = UIColor.black
button.setTitleColor(UIColor.white, for: .normal)
button.setTitle("\(i)", for: .normal)
button.tag = i
button.addTarget(self, action: #selector(self.selectContent(_:)), for: .touchUpInside)
buttons.append(button)
addSubview(button)
}
}
func selectContent(_ sender: UIButton) {
select(contentIndex: sender.tag)
}
}
您只需要继承 "CoverView"。
MIT 许可证。 LICENSE