YKPopupDialogView is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "YKPopupDialogView"
- Import the pod
import YKPopupDialogView
- Create a YKPopupDialogView instance
let popupDialogView = YKPopupDialogView()
- Set content
popupDialogView.setTitle("Title")
popupDialogView.setMessage("Message")
popupDialogView.setImage(UIImage(named: "imageName"))
- Add Buttons
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)
- Display
popupDialogView.show()
- Fade-In
- Fade-Out
- Zoom-In
- Zoom-Out
- Slide-Bottom
- Slide-Top
- Slide-Left
- Slide-Right
You can access the properties below from YKPopupDialogView's instance before you call the show
function
as you can see in the example and customize it any way you like and need.
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 9.0+
- Swift 3.0+
- Add custom animations
- CocoaPods support
- Carthage support
Yusuf Kıldan, kildanyusuf@gmail.com
YKPopupDialogView is available under the MIT license. See the LICENSE file for more info.