JDPopup is a light weight popup container which shows a popup view with an arrow that indicates the sender's position.
pod 'JDPopup'
Add folder JDPopup into your project
If you install via CocoaPods, you only need to import one class:
import JDPopup
config |
---|
customWidth |
customHeight |
arrowWidth |
arrowHeight |
barTitleColor |
contentBgColor |
borderColor |
borderWidth |
backgoundColor |
cornerRadius |
barHeight |
tapScreenClose |
lrSpacing |
tbSpacing |
duration |
shadowColor |
shadowAlpha |
exitBtnTintColor |
exitBtnImage |
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)
}
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)
}
Floral photo created by rawpixel.com - www.freepik.com
JDPopup is available under the MIT
license. See the LICENSE
file for more info.