KUIActionSheet
Swift的自定义UIActionSheet
需求
- iOS 8.0+
- Xcode 9.0
- Swift 4.2
- Swift 3.0 (2.0.4)
安装
CocoaPods
KUIActionSheet通过CocoaPods提供。要安装它,只需将以下行添加到您的Podfile中:
pod "KUIActionSheet"
使用说明
KUIActionSheet
import KUIActionSheet
let actionSheet = KUIActionSheet.view(parentViewController: self)
actionSheet?.add(customView: UIView<KUIActionSheetItemViewProtocol>)
actionSheet?.add(item: KUIActionSheetItem(title: "Menu1", destructive: false) { [weak self] (item) in
print(item.title)
})
actionSheet?.add(item: KUIActionSheetItem(asyncTitle: { (completion) -> Void in
DispatchQueue.main.asyncAfter(deadline: .now() + 2.0, execute: {
completion("Async Title")
})
}, handler: { (item) in
print(item)
}))
actionSheet?.show()
自定义视图
class CustomView: UIView, KUIActionSheetItemViewProtocol {
func ... () {
actionSheet?.dismiss()
}
}
自定义主题
public protocol KUIActionSheetProtocol {
var backgroundColor: UIColor { get }
var showAnimationDuration: NSTimeInterval { get }
var dimissAnimationDuration: NSTimeInterval { get }
var blurEffectStyle: UIBlurEffectStyle { get }
var itemTheme: KUIActionSheetItemTheme { get }
}
public protocol KUIActionSheetItemTheme {
var height: CGFloat { get }
var font: UIFont { get }
var titleColor: UIColor { get }
var destructiveTitleColor: UIColor { get }
}
作者
Kim Taeun (kofktu), [email protected]
许可证
KUIActionSheet遵循MIT
许可证。更多信息请参阅LICENSE
文件。