Skip to content

Simple and customizable popup dialog view with custom animations.

License

Notifications You must be signed in to change notification settings

yusufkildan/YKPopupDialogView

Repository files navigation

YKPopupDialogView

Preview

Installation

YKPopupDialogView is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "YKPopupDialogView"

Usage

  1. Import the pod
import YKPopupDialogView
  1. Create a YKPopupDialogView instance
let popupDialogView = YKPopupDialogView()
  1. Set content
popupDialogView.setTitle("Title")
popupDialogView.setMessage("Message")        
popupDialogView.setImage(UIImage(named: "imageName"))
  1. 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)
  1. Display
popupDialogView.show()

Animation options

  • Fade-In
  • Fade-Out
  • Zoom-In
  • Zoom-Out
  • Slide-Bottom
  • Slide-Top
  • Slide-Left
  • Slide-Right

Customizing

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.

Example

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)

All properties

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!

Requirements

  • iOS 9.0+
  • Swift 3.0+

Roadmap

  • Add custom animations
  • CocoaPods support
  • Carthage support

Author

Yusuf Kıldan, kildanyusuf@gmail.com

License

YKPopupDialogView is available under the MIT license. See the LICENSE file for more info.

About

Simple and customizable popup dialog view with custom animations.

Resources

License

Stars

Watchers

Forks

Packages

No packages published