要运行示例项目,请克隆仓库,然后首先从示例目录运行 pod install
KKSActionSheet 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中
pod "KKSActionSheet"
如果您需要将其添加到 swift2.2 版本
pod 'KKSActionSheet', '~> 0.1.5'
首先导入库
import KKSActionSheet
之后创建实例
let actionSheet = KKActionSheet()
然后添加数据
actionSheet.actionSheetData = [KKActionSheetData(image: UIImage(named:"picker_photo"),title: "From lib",complitionHandler:nil),
KKActionSheetData(image: UIImage(named:"picker_camera"),title:"Make photo",complitionHandler:nil),
KKActionSheetData(image: UIImage(named:"picker_close"),title: "Close",complitionHandler: { Void in
print("Handler used")
})]
要显示动作表,请调用
actionSheet.showActionSheetWithSender(sender:self)
就是这样。它与带有和无导航栏一起工作。
您还可以配置一些属性
/* action sheet height min(50) max(100) */
public var actionSheetItemHeight: CGFloat
/* Colors */
/* textColor for Normal state */
public var actionSheetCellTextColorNormal: UIColor?
/* backgroundColor for Normal state */
public var actionSheetCellBGColorNormal: UIColor?
/* textColor for Highlighted state */
public var actionSheetCellTextColorHighlighted: UIColor?
/* backgroundColor for Highlighted state */
public var actionSheetCellBGColorHighlighted: UIColor?
如果您想为所有表格使用不同的颜色,请使用它
let data = KKActionSheetData(image: UIImage(),title:"1",complitionHandler:nil)
data.titleColor = .orangeColor()
customActionSheet.actionSheetData = [data,
KKActionSheetData(image:UIImage(named:"picker_camera"),title:"2",complitionHandler:nil),
KKActionSheetData(image:UIImage(named:"picker_close"),title: "3",complitionHandler: { Void in
print("HAndler used")
button.backgroundColor = .orangeColor();
})]
k_krizhanovskii, [email protected]
KKSActionSheet 在 MIT 许可证下可用。
以下允许任何获得本软件及其相关文档文件(“软件”)副本的人免费处置软件,而无权限制使用、复制、修改、合并、发布、分发、再许可或出售软件的副本,并允许向获得软件的人提供副本以进行上述活动,前提是
以下版权声明和许可声明应包含在软件的所有副本或主要部分中。
软件按“原样”提供,不提供任何明示或暗示的保证,包括但不限于适销性、针对特定目的的适用性和非侵权性保证。在任何情况下,作者或版权持有人不对任何主张、损害或其他责任负责,也不论是合同、侵权或其他方式,起因于软件、软件的使用或其他与此软件的使用相关的事项。