Skip to content

jdleung/JDPopup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JDPopup

JDPopup is a light weight popup container which shows a popup view with an arrow that indicates the sender's position.

SreenShots

Installation

CocoaPod

pod 'JDPopup'

Manually

Add folder JDPopup into your project

Import

If you install via CocoaPods, you only need to import one class:

import JDPopup

Usage

Customization

config
customWidth
customHeight
arrowWidth
arrowHeight
barTitleColor
contentBgColor
borderColor
borderWidth
backgoundColor
cornerRadius
barHeight
tapScreenClose
lrSpacing
tbSpacing
duration
shadowColor
shadowAlpha
exitBtnTintColor
exitBtnImage

Create an instance of JDPopup

Sender UIButton

func showPopup(_ sender: UIButton) {  
    let imageView = UIImageView()
    imageView.image = UIImage(named: "plant")
  
    let popView = JDPopup(sender: sender, barTitle: "A Popup Image View", contentViewAdapter: { contentView in
                imageView.frame = CGRect(x: 0, y: 0, width: contentView.frame.width, height: contentView.frame.height)
                contentView.addSubview(imageView)
            })
  
    popView.config.customHeight = 300.0
    self.present(popView, animated: false, completion: nil)
}

Sender UIBarButtonItem

func showPopup(_ sender: UIBarButtonItem, event: UIEvent) {
    let imageView = UIImageView()
    imageView.image = UIImage(named: "plant")
  
    let popView = JDPopup(event: event, barTitle: "A Popup Image View", contentViewAdapter: { contentView in
                imageView.frame = CGRect(x: 0, y: 0, width: contentView.frame.width, height: contentView.frame.height)
                contentView.addSubview(imageView)
            })
  
    popView.config.customHeight = 300.0
    self.present(popView, animated: false, completion: nil)
}

Demo project photo

 Floral photo created by rawpixel.com - www.freepik.com

License

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