Floating
Floating是一个非常灵活的叠加库。
要求
- iOS 10.0+
- Xcode 9.2+, Swift 4.1
CocoaPods
pod 'Floating'
Carthage
github "hirohisa/Floating"
使用
present
import Floating
func didTapButton(_ sender: UIButton) {
let handler: FloatingView<UITextField>.Handler = { (state, object) in
print(state)
print(object)
}
FloatingView(view)
.configure(backgroundColor: backgroundColor, handler: handler)
.present(from: sender.frame)
}
使用生命周期处理
观察者
// Notification.Name
let FloatingViewWillPresent
let FloatingViewDidPresent
let FloatingViewWillDismiss
let FloatingViewDidDismiss
NotificationCenter.default.addObserver(forName: .FloatingViewWillPresent, object: nil, queue: nil) { (notification) in
...
}
闭包
// State
enum FloatingView.State {
case willPresent
case didPresent
case willDismiss
case didDismiss
}
let handler: FloatingView<T>.Handler = { (state: State, object: T) in
...
}
FloatingView(view)
.configure(handler: handler)
许可证
浮动视图(Floating)可在MIT许可证下使用。