JFPopup
Github
https://github.com/JerryFans/JFPopup
JFPopup is a Swift Module help you popup your custom view easily.
Support 3 way to popup, Drawer, Dialog and BottomSheet.
Example
To run the example project, clone the repo, and run pod install
from the Example directory first.
Quick Create your popup view
Dialog
dialog mode, like UIAlertConroller, you also can use your custom alert view
self.popup.dialog {
let v = UIView(frame: CGRect(x: 0, y: 0, width: 200, height: 200))
v.backgroundColor = .red
return v
}
Drawer
drawer mode , support direction left or right
//default left
self.popup.drawer {
let v = DrawerView(frame: CGRect(x: 0, y: 0, width: CGSize.jf.screenWidth(), height: CGSize.jf.screenHeight()))
v.closeHandle = { [weak self] in
self?.popup.dismiss()
}
return v
}
self.popup.drawer(with: .right) {
let v = UIView(frame: CGRect(x: 0, y: 0, width: 200, height: CGSize.jf.screenHeight()))
v.backgroundColor = .red
return v
}
Bottomsheet
Like Flutter Bottomsheet, popup a custom container from bottom 。 You alose can use this mode to build your custom UIActionSheet.
self.popup.bottomSheet {
let v = UIView(frame: CGRect(x: 0, y: 0, width: CGSize.jf.screenWidth(), height: 300))
v.backgroundColor = .red
return v
}
Gerenal Kit
Wechat Style ActionSheet
self.popup.actionSheet {
[
JFPopupAction(with: "拍摄", subTitle: "照片或视频照片", clickActionCallBack: { [weak self] in
self?.pushVC()
}),
JFPopupAction(with: "从手机相册选择", subTitle: nil, clickActionCallBack: {
}),
JFPopupAction(with: "用秒剪制作视频", subTitle: nil, clickActionCallBack: {
}),
]
}
Create With VC Mode
This way suggest to adapt Objc, you can write your entension method to compatibility Objc.
Extends Base PopUpVC (Like Extends UITableview to write your custom table view)
var config = JFPopupConfig.bottomSheet
config.isDismissible = false
let vc = TestCustomViewController(with: config)
vc.show(with: self)
Call Back Way
var config = JFPopupConfig.dialog
config.bgColor = .clear
let vc = JFPopupController(with: config, popupProtocol: self) {
let view: UIView = {
let view = UIView()
view.frame = CGRect(x: 0, y: 0, width: 200, height: 200)
view.layer.cornerRadius = 12
view.backgroundColor = .black
return view
}()
return view
}
vc.show(with: self)
Requirements
Installation
JFPopup is available through CocoaPods. To install
it, simply add the following line to your Podfile:
pod 'JFPopup', '1.0.0'
Author
JerryFans, fanjiarong_haohao@163.com
License
JFPopup is available under the MIT license. See the LICENSE file for more info.
Top comments (0)