YKPopupDialogView 0.1.0

YKPopupDialogView 0.1.0

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布最新发布2017年8月
SwiftSwift 版本3.0
SPM支持 SPM

Yusuf Kıldan 维护。



YKPopupDialogView

预览

安装

YKPopupDialogView 可以通过 CocoaPods 来安装。要安装它,只需将以下行添加到您的 Podfile 中

pod "YKPopupDialogView"

使用方法

  1. 导入 Pod
import YKPopupDialogView
  1. 创建 YKPopupDialogView 实例
let popupDialogView = YKPopupDialogView()
  1. 设置内容
popupDialogView.setTitle("Title")
popupDialogView.setMessage("Message")        
popupDialogView.setImage(UIImage(named: "imageName"))
  1. 添加按钮
let defaultButton = popupDialogView.addButton("Default", type: YKPopupDialogButtonType.default)        
defaultButton.addTarget(self, action: #selector(popupDialogButtonTapped(_:)), for: UIControlEvents.touchUpInside)

let cancelButton = popupDialogView.addButton("Cancel", type: YKPopupDialogButtonType.cancel)
cancelButton.addTarget(self, action: #selector(popupDialogButtonTapped(_:)), for: UIControlEvents.touchUpInside)
  1. 显示
popupDialogView.show()

动画选项

  • 淡入
  • 淡出
  • 缩放进入
  • 缩放退出
  • 从底部滑入
  • 从顶部滑入
  • 从左侧滑入
  • 从右侧滑入

自定义

在调用 `show` 函数之前,您可以像示例中那样从 YKPopupDialogView 的实例中访问以下属性,并以您喜欢的方式自定义。

示例

let popupDialogView: YKPopupDialogView = YKPopupDialogView()

popupDialogView.closeOnTap = false
popupDialogView.popupViewCornerRadius = 30
popupDialogView.buttonAlignment = .horizontal
popupDialogView.animationDuration = 0.2
popupDialogView.overlayViewBackgroundColor = UIColor(red: 117.0 / 255.0, green: 117.0 / 255.0, blue: 117.0 / 255.0, alpha: 0.8)
popupDialogView.imageSize = CGSize(width: 120.24, height: 104.04)
popupDialogView.setImage(UIImage(named: "geofencePermissionIcon")!)

popupDialogView.setTitle("Enable Geofencing", attributes: [NSFontAttributeName: UIFont(name: "Kanit-SemiBold", size: 17.0)!, NSForegroundColorAttributeName: UIColor(red: 33.0 / 255.0, green: 33.0 / 255.0, blue: 33.0 / 255.0, alpha: 1.0)])

popupDialogView.setMessage("Enable geofencing to get instant notifications for assignments nearby.", attributes: [NSFontAttributeName: UIFont(name: "Kanit-Regular", size: 16.0)!, NSForegroundColorAttributeName: UIColor(red: 117.0 / 255.0, green: 117.0 / 255.0, blue: 117.0 / 255.0, alpha: 1.0)])

let cancelButton = popupDialogView.addButton("Cancel", textColor: UIColor(red: 189.0 / 255.0, green: 189.0 / 255.0, blue: 189.0 / 255.0, alpha: 1.0), backgroundColor: UIColor.clear, font: UIFont(name: "Kanit-Medium", size: 17.0)!, cornerRadius: 0)
cancelButton.addTarget(self, action: #selector(cancelButtonTapped(_:)), for: .touchUpInside)

let enableButton = popupDialogView.addButton("Enable", textColor: UIColor(red: 245.0 / 255.0, green: 0.0 / 255.0, blue: 7.0 / 255.0, alpha: 0.8), backgroundColor: UIColor.clear, font: UIFont(name: "Kanit-SemiBold", size: 18.0)!, cornerRadius: 0)
enableButton.addTarget(self, action: #selector(enableButtonTapped(_:)), for: .touchUpInside)

popupDialogView.show(YKPopupDialogAnimationPattern.fadeInOut)

所有属性

public var closeOnTap: Bool

public var popupViewInnerPadding: CGFloat

public var popupViewWidth: CGFloat

public var popupViewCornerRadius: CGFloat

public var popupViewBackgroundColor: UIColor

public var overlayViewBackgroundColor: UIColor

public var buttonHeight: CGFloat

public var buttonPadding: CGFloat

public var imageSize: CGSize

public var animationDuration: TimeInterval

public var buttonAlignment: YKPopupDialogView.YKPopupDialogButtonAlignment

public private(set) var isShown: Bool!

要求

  • iOS 10.0+
  • Swift 3+

路线图

  • [x] 添加自定义动画
  • [x] CocoaPods 支持
  • [ ] Carthage 支持

作者

Yusuf Kıldan,[email protected]

许可证

YKPopupDialogView 在 MIT 许可下可用。有关更多信息,请参阅 LICENSE 文件。