├── ZJJPopup.gif ├── ZJJPopup ├── Assets.xcassets │ ├── Contents.json │ ├── weix_icon.imageset │ │ ├── weix_icon.png │ │ ├── weix_icon@2x.png │ │ ├── weix_icon@3x.png │ │ └── Contents.json │ ├── buneng_icon.imageset │ │ ├── buneng_icon.png │ │ ├── buneng_icon@2x.png │ │ ├── buneng_icon@3x.png │ │ └── Contents.json │ ├── dizhic_icon.imageset │ │ ├── dizhic_icon.png │ │ ├── dizhic_icon@2x.png │ │ ├── dizhic_icon@3x.png │ │ └── Contents.json │ ├── chengong_icon.imageset │ │ ├── chengong_icon.png │ │ ├── chengong_icon@2x.png │ │ ├── chengong_icon@3x.png │ │ └── Contents.json │ ├── AccentColor.colorset │ │ └── Contents.json │ └── AppIcon.appiconset │ │ └── Contents.json ├── ZJJPopup │ ├── ZJJOptionProtocol.swift │ ├── ZJJOption.swift │ ├── ZJJPopup.swift │ ├── ZJJPopupModel.swift │ ├── ZJJDefaultPickerView.swift │ ├── ZJJDefaultSelectTableView.swift │ ├── ZJJPopupTopView.swift │ └── ZJJPopupView.swift ├── Example │ ├── ZJJDataModel.swift │ ├── ZJJCustomView.swift │ ├── ZJJCustomCell.swift │ ├── ZJJCustomView.xib │ ├── ZJJConfigModel.swift │ ├── ViewController.swift │ └── ZJJCustomCell.xib ├── AppDelegate.swift ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist └── SceneDelegate.swift ├── ZJJPopup.xcodeproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── project.pbxproj ├── LICENSE ├── README.md └── .gitignore /ZJJPopup.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/04zhujunjie/ZJJPopup/HEAD/ZJJPopup.gif -------------------------------------------------------------------------------- /ZJJPopup/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /ZJJPopup/Assets.xcassets/weix_icon.imageset/weix_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/04zhujunjie/ZJJPopup/HEAD/ZJJPopup/Assets.xcassets/weix_icon.imageset/weix_icon.png -------------------------------------------------------------------------------- /ZJJPopup/Assets.xcassets/buneng_icon.imageset/buneng_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/04zhujunjie/ZJJPopup/HEAD/ZJJPopup/Assets.xcassets/buneng_icon.imageset/buneng_icon.png -------------------------------------------------------------------------------- /ZJJPopup/Assets.xcassets/dizhic_icon.imageset/dizhic_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/04zhujunjie/ZJJPopup/HEAD/ZJJPopup/Assets.xcassets/dizhic_icon.imageset/dizhic_icon.png -------------------------------------------------------------------------------- /ZJJPopup/Assets.xcassets/weix_icon.imageset/weix_icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/04zhujunjie/ZJJPopup/HEAD/ZJJPopup/Assets.xcassets/weix_icon.imageset/weix_icon@2x.png -------------------------------------------------------------------------------- /ZJJPopup/Assets.xcassets/weix_icon.imageset/weix_icon@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/04zhujunjie/ZJJPopup/HEAD/ZJJPopup/Assets.xcassets/weix_icon.imageset/weix_icon@3x.png -------------------------------------------------------------------------------- /ZJJPopup/Assets.xcassets/buneng_icon.imageset/buneng_icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/04zhujunjie/ZJJPopup/HEAD/ZJJPopup/Assets.xcassets/buneng_icon.imageset/buneng_icon@2x.png -------------------------------------------------------------------------------- /ZJJPopup/Assets.xcassets/buneng_icon.imageset/buneng_icon@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/04zhujunjie/ZJJPopup/HEAD/ZJJPopup/Assets.xcassets/buneng_icon.imageset/buneng_icon@3x.png -------------------------------------------------------------------------------- /ZJJPopup/Assets.xcassets/chengong_icon.imageset/chengong_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/04zhujunjie/ZJJPopup/HEAD/ZJJPopup/Assets.xcassets/chengong_icon.imageset/chengong_icon.png -------------------------------------------------------------------------------- /ZJJPopup/Assets.xcassets/dizhic_icon.imageset/dizhic_icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/04zhujunjie/ZJJPopup/HEAD/ZJJPopup/Assets.xcassets/dizhic_icon.imageset/dizhic_icon@2x.png -------------------------------------------------------------------------------- /ZJJPopup/Assets.xcassets/dizhic_icon.imageset/dizhic_icon@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/04zhujunjie/ZJJPopup/HEAD/ZJJPopup/Assets.xcassets/dizhic_icon.imageset/dizhic_icon@3x.png -------------------------------------------------------------------------------- /ZJJPopup/Assets.xcassets/chengong_icon.imageset/chengong_icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/04zhujunjie/ZJJPopup/HEAD/ZJJPopup/Assets.xcassets/chengong_icon.imageset/chengong_icon@2x.png -------------------------------------------------------------------------------- /ZJJPopup/Assets.xcassets/chengong_icon.imageset/chengong_icon@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/04zhujunjie/ZJJPopup/HEAD/ZJJPopup/Assets.xcassets/chengong_icon.imageset/chengong_icon@3x.png -------------------------------------------------------------------------------- /ZJJPopup.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ZJJPopup/Assets.xcassets/AccentColor.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "idiom" : "universal" 5 | } 6 | ], 7 | "info" : { 8 | "author" : "xcode", 9 | "version" : 1 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /ZJJPopup/ZJJPopup/ZJJOptionProtocol.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ZJJOptionProtocol.swift 3 | // ZJJPopupView 4 | // 5 | // Created by weiqu on 2021/4/28. 6 | // 7 | 8 | import UIKit 9 | 10 | protocol ZJJOptionProtocol { 11 | var jj_optionValue:String?{set get} //必须 12 | } 13 | -------------------------------------------------------------------------------- /ZJJPopup/ZJJPopup/ZJJOption.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ZJJOption.swift 3 | // ZJJPopup 4 | // 5 | // Created by weiqu on 2021/4/26. 6 | // 7 | 8 | import UIKit 9 | 10 | struct ZJJOption { 11 | var optionArray:[ZJJOptionProtocol] = [] //选择的列表 12 | var selectModel:ZJJOptionProtocol? //选择的对象 13 | } 14 | -------------------------------------------------------------------------------- /ZJJPopup.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ZJJPopup/Assets.xcassets/weix_icon.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "filename" : "weix_icon.png", 5 | "idiom" : "universal", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "filename" : "weix_icon@2x.png", 10 | "idiom" : "universal", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "filename" : "weix_icon@3x.png", 15 | "idiom" : "universal", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "author" : "xcode", 21 | "version" : 1 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ZJJPopup/Assets.xcassets/buneng_icon.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "filename" : "buneng_icon.png", 5 | "idiom" : "universal", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "filename" : "buneng_icon@2x.png", 10 | "idiom" : "universal", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "filename" : "buneng_icon@3x.png", 15 | "idiom" : "universal", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "author" : "xcode", 21 | "version" : 1 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ZJJPopup/Assets.xcassets/dizhic_icon.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "filename" : "dizhic_icon.png", 5 | "idiom" : "universal", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "filename" : "dizhic_icon@2x.png", 10 | "idiom" : "universal", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "filename" : "dizhic_icon@3x.png", 15 | "idiom" : "universal", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "author" : "xcode", 21 | "version" : 1 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ZJJPopup/Assets.xcassets/chengong_icon.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "filename" : "chengong_icon.png", 5 | "idiom" : "universal", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "filename" : "chengong_icon@2x.png", 10 | "idiom" : "universal", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "filename" : "chengong_icon@3x.png", 15 | "idiom" : "universal", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "author" : "xcode", 21 | "version" : 1 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ZJJPopup/Example/ZJJDataModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ZJJDataModel.swift 3 | // ZJJPopup 4 | // 5 | // Created by weiqu on 2021/4/29. 6 | // 7 | 8 | 9 | 10 | import UIKit 11 | 12 | struct ZJJDataModel:ZJJOptionProtocol { 13 | var jj_optionValue: String?{ 14 | set{ 15 | 16 | } 17 | get { 18 | return "\(title ?? "")--\(row ?? 0)" 19 | } 20 | } 21 | var title:String? 22 | var row:Int? 23 | } 24 | 25 | class ZJJCustomModel:NSObject,ZJJOptionProtocol{ 26 | var jj_optionValue: String?{ 27 | set{ 28 | 29 | } 30 | get { 31 | return "\(title ?? "")" 32 | } 33 | } 34 | var icon:String? 35 | var title:String? 36 | 37 | } 38 | -------------------------------------------------------------------------------- /ZJJPopup/Example/ZJJCustomView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ZJJCustomView.swift 3 | // ZJJPopup 4 | // 5 | // Created by weiqu on 2021/4/29. 6 | // 7 | 8 | import UIKit 9 | 10 | typealias ZJJCustomViewCloseBlock = () -> () 11 | 12 | class ZJJCustomView: UIView { 13 | 14 | var closeBlock:ZJJCustomViewCloseBlock? 15 | /* 16 | // Only override draw() if you perform custom drawing. 17 | // An empty implementation adversely affects performance during animation. 18 | override func draw(_ rect: CGRect) { 19 | // Drawing code 20 | } 21 | */ 22 | 23 | func close(block:ZJJCustomViewCloseBlock?) { 24 | self.closeBlock = block 25 | } 26 | 27 | @IBAction func closeBtnClick(_ sender: UIButton) { 28 | if let block = self.closeBlock { 29 | block() 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Jeking 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /ZJJPopup/Example/ZJJCustomCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ZJJCustomCell.swift 3 | // ZJJPopup 4 | // 5 | // Created by weiqu on 2021/4/29. 6 | // 7 | 8 | import UIKit 9 | 10 | class ZJJCustomCell: UITableViewCell { 11 | 12 | @IBOutlet weak private var iconImageView: UIImageView! 13 | 14 | @IBOutlet weak private var titleLabel: UILabel! 15 | @IBOutlet weak var selectImageView: UIImageView! 16 | var model:ZJJCustomModel!{ 17 | didSet{ 18 | self.updateCell() 19 | } 20 | } 21 | 22 | override func awakeFromNib() { 23 | super.awakeFromNib() 24 | // Initialization code 25 | } 26 | 27 | func updateCell() { 28 | self.iconImageView.image = UIImage.init(named: model.icon ?? "") 29 | self.iconImageView.jj_setCornersRadius(radius: self.iconImageView.frame.size.width/2.0, roundingCorners: .allCorners) 30 | self.titleLabel.text = model.jj_optionValue 31 | } 32 | 33 | 34 | override func setSelected(_ selected: Bool, animated: Bool) { 35 | super.setSelected(selected, animated: animated) 36 | 37 | // Configure the view for the selected state 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /ZJJPopup/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // ZJJPopup 4 | // 5 | // Created by weiqu on 2021/4/28. 6 | // 7 | 8 | import UIKit 9 | 10 | @main 11 | class AppDelegate: UIResponder, UIApplicationDelegate { 12 | 13 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 14 | // Override point for customization after application launch. 15 | return true 16 | } 17 | 18 | } 19 | 20 | @available(iOS 13.0, *) 21 | extension AppDelegate { 22 | // MARK: UISceneSession Lifecycle 23 | 24 | func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 25 | // Called when a new scene session is being created. 26 | // Use this method to select a configuration to create the new scene with. 27 | return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 28 | } 29 | 30 | func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { 31 | // Called when the user discards a scene session. 32 | // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 33 | // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 34 | } 35 | } 36 | 37 | -------------------------------------------------------------------------------- /ZJJPopup/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # ZJJPopup 3 | 4 | ### 效果图 5 | ![image](https://github.com/04zhujunjie/ZJJPopup/blob/main/ZJJPopup.gif) 6 | 7 | ### 特点: 8 | 1、弹窗可以选择显示在window,viewController, navigationController上 9 | 2、弹窗的样式可以通过 ZJJPopupModel对象来设置 10 | 3、可以自定义弹窗 ,支持毛玻璃效果 11 | 4、提供默认的选择器(UIPickerView和UITableView)的弹框 12 | 5、弹窗的头部视图,可以根据文本标题和按钮文本来动态调节头部视图的高度 13 | 14 | ### 弹窗的样式设置:       15 | 可以通过ZJJPopupModel对象来进行设置 16 |     17 | ``` 18 | struct ZJJPopupModel { 19 | 20 | var animationType:ZJJPopupAnimationType = .move //弹框出现样式 21 | var showInType:ZJJPopupViewShowInType = .window //弹框添加到哪里,默认是在window上 22 | var popupViewRadius:CGFloat = 10 //设置popupView的圆角 23 | var isTouchHidden:Bool = true //点击遮罩层,是否隐藏弹框视图 24 | var isConfirmHidden:Bool = true //点击确定按钮,是否隐藏弹框视图 25 | var contentViewMinHeight:CGFloat = 220 //contentView内容的最小高度 26 | var maskLayerColor:UIColor = UIColor.init(red:0, green: 0, blue:0, alpha: 0.5) //遮罩层的颜色 27 | var blurEffectStyle:ZJJBlurEffectStyle = .none //设置毛玻璃效果,设置为none,显示遮罩层的颜色 28 | var backgroundColor:UIColor = .white{ 29 | didSet{ 30 | self.topViewConfig.backgroundColor = backgroundColor 31 | } 32 | } //背景颜色 33 | 34 | var topViewConfig:ZJJPopupTopViewConfig = ZJJPopupTopViewConfig() //topView配置 35 | } 36 | 37 | ``` 38 | 39 | ### 如何使用默认的弹窗选择器(UIPickerView和UITableView) 40 | 41 | #### 一、创建的数据结构体或者模型对象遵循 ZJJOptionProtocol协议,jj_optionValue值是作为选择器列表中显示的值 42 | ``` 43 | protocol ZJJOptionProtocol { 44 | var jj_optionValue:String?{set get} 45 | } 46 | ``` 47 | 48 | #### 二、创建ZJJPopupModel对象来设置弹窗的样式,创建ZJJOption对象来存储要显示的选择列表数据和列表中选中的数据 49 | ``` 50 | struct ZJJOption { 51 | var optionArray:[ZJJOptionProtocol] = [] //选择的列表 52 | var selectModel:ZJJOptionProtocol? //选择的对象 53 | } 54 | ``` 55 | 56 | #### 三、可以使用ZJJPopup提供的便捷的方法,如果需要自定义选择器或者自定义弹窗,可以参照ZJJPopup内部的实现 57 | 58 | -------------------------------------------------------------------------------- /ZJJPopup/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "scale" : "2x", 6 | "size" : "20x20" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "scale" : "3x", 11 | "size" : "20x20" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "scale" : "2x", 16 | "size" : "29x29" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "scale" : "3x", 21 | "size" : "29x29" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "scale" : "2x", 26 | "size" : "40x40" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "scale" : "3x", 31 | "size" : "40x40" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "scale" : "2x", 36 | "size" : "60x60" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "scale" : "3x", 41 | "size" : "60x60" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "scale" : "1x", 46 | "size" : "20x20" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "scale" : "2x", 51 | "size" : "20x20" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "scale" : "1x", 56 | "size" : "29x29" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "scale" : "2x", 61 | "size" : "29x29" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "scale" : "1x", 66 | "size" : "40x40" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "scale" : "2x", 71 | "size" : "40x40" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "scale" : "1x", 76 | "size" : "76x76" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "scale" : "2x", 81 | "size" : "76x76" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "scale" : "2x", 86 | "size" : "83.5x83.5" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "scale" : "1x", 91 | "size" : "1024x1024" 92 | } 93 | ], 94 | "info" : { 95 | "author" : "xcode", 96 | "version" : 1 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /ZJJPopup/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UIApplicationSceneManifest 24 | 25 | UIApplicationSupportsMultipleScenes 26 | 27 | UISceneConfigurations 28 | 29 | UIWindowSceneSessionRoleApplication 30 | 31 | 32 | UISceneConfigurationName 33 | Default Configuration 34 | UISceneDelegateClassName 35 | $(PRODUCT_MODULE_NAME).SceneDelegate 36 | UISceneStoryboardFile 37 | Main 38 | 39 | 40 | 41 | 42 | UIApplicationSupportsIndirectInputEvents 43 | 44 | UILaunchStoryboardName 45 | LaunchScreen 46 | UIMainStoryboardFile 47 | Main 48 | UIRequiredDeviceCapabilities 49 | 50 | armv7 51 | 52 | UISupportedInterfaceOrientations 53 | 54 | UIInterfaceOrientationPortrait 55 | UIInterfaceOrientationLandscapeLeft 56 | UIInterfaceOrientationLandscapeRight 57 | 58 | UISupportedInterfaceOrientations~ipad 59 | 60 | UIInterfaceOrientationPortrait 61 | UIInterfaceOrientationPortraitUpsideDown 62 | UIInterfaceOrientationLandscapeLeft 63 | UIInterfaceOrientationLandscapeRight 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /ZJJPopup/SceneDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SceneDelegate.swift 3 | // ZJJPopup 4 | // 5 | // Created by weiqu on 2021/4/28. 6 | // 7 | 8 | import UIKit 9 | 10 | @available(iOS 13, *) 11 | class SceneDelegate: UIResponder, UIWindowSceneDelegate { 12 | 13 | var window: UIWindow? 14 | 15 | 16 | func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { 17 | // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. 18 | // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. 19 | // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). 20 | guard let _ = (scene as? UIWindowScene) else { return } 21 | } 22 | 23 | func sceneDidDisconnect(_ scene: UIScene) { 24 | // Called as the scene is being released by the system. 25 | // This occurs shortly after the scene enters the background, or when its session is discarded. 26 | // Release any resources associated with this scene that can be re-created the next time the scene connects. 27 | // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). 28 | } 29 | 30 | func sceneDidBecomeActive(_ scene: UIScene) { 31 | // Called when the scene has moved from an inactive state to an active state. 32 | // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. 33 | } 34 | 35 | func sceneWillResignActive(_ scene: UIScene) { 36 | // Called when the scene will move from an active state to an inactive state. 37 | // This may occur due to temporary interruptions (ex. an incoming phone call). 38 | } 39 | 40 | func sceneWillEnterForeground(_ scene: UIScene) { 41 | // Called as the scene transitions from the background to the foreground. 42 | // Use this method to undo the changes made on entering the background. 43 | } 44 | 45 | func sceneDidEnterBackground(_ scene: UIScene) { 46 | // Called as the scene transitions from the foreground to the background. 47 | // Use this method to save data, release shared resources, and store enough scene-specific state information 48 | // to restore the scene back to its current state. 49 | } 50 | 51 | 52 | } 53 | 54 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## User settings 6 | xcuserdata/ 7 | 8 | ## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) 9 | *.xcscmblueprint 10 | *.xccheckout 11 | 12 | ## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) 13 | build/ 14 | DerivedData/ 15 | *.moved-aside 16 | *.pbxuser 17 | !default.pbxuser 18 | *.mode1v3 19 | !default.mode1v3 20 | *.mode2v3 21 | !default.mode2v3 22 | *.perspectivev3 23 | !default.perspectivev3 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | 28 | ## App packaging 29 | *.ipa 30 | *.dSYM.zip 31 | *.dSYM 32 | 33 | ## Playgrounds 34 | timeline.xctimeline 35 | playground.xcworkspace 36 | 37 | # Swift Package Manager 38 | # 39 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 40 | # Packages/ 41 | # Package.pins 42 | # Package.resolved 43 | # *.xcodeproj 44 | # 45 | # Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata 46 | # hence it is not needed unless you have added a package configuration file to your project 47 | # .swiftpm 48 | 49 | .build/ 50 | 51 | # CocoaPods 52 | # 53 | # We recommend against adding the Pods directory to your .gitignore. However 54 | # you should judge for yourself, the pros and cons are mentioned at: 55 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 56 | # 57 | # Pods/ 58 | # 59 | # Add this line if you want to avoid checking in source code from the Xcode workspace 60 | # *.xcworkspace 61 | 62 | # Carthage 63 | # 64 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 65 | # Carthage/Checkouts 66 | 67 | Carthage/Build/ 68 | 69 | # Accio dependency management 70 | Dependencies/ 71 | .accio/ 72 | 73 | # fastlane 74 | # 75 | # It is recommended to not store the screenshots in the git repo. 76 | # Instead, use fastlane to re-generate the screenshots whenever they are needed. 77 | # For more information about the recommended setup visit: 78 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 79 | 80 | fastlane/report.xml 81 | fastlane/Preview.html 82 | fastlane/screenshots/**/*.png 83 | fastlane/test_output 84 | 85 | # Code Injection 86 | # 87 | # After new code Injection tools there's a generated folder /iOSInjectionProject 88 | # https://github.com/johnno1962/injectionforxcode 89 | 90 | iOSInjectionProject/ 91 | -------------------------------------------------------------------------------- /ZJJPopup/Example/ZJJCustomView.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /ZJJPopup/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /ZJJPopup/ZJJPopup/ZJJPopup.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ZJJPopup.swift 3 | // ZJJPopup 4 | // 5 | // Created by weiqu on 2021/4/28. 6 | // 7 | 8 | import UIKit 9 | 10 | typealias ZJJPopupPickerBlock = (ZJJDefaultPickerView,ZJJPopupView,ZJJOptionProtocol?,UIButton) -> () 11 | typealias ZJJPopupTableViewBlock = (ZJJDefaultSelectTableView,ZJJPopupView,ZJJOptionProtocol?,UIButton) -> () 12 | 13 | class ZJJPopup { 14 | 15 | @discardableResult 16 | static public func tableView(frame:CGRect = CGRect.init(x: 0, y: 0, width: UIScreen.main.bounds.size.width, height:220),optionModel:ZJJOption,title:String,confirmBlock:ZJJPopupTableViewBlock? = nil) -> (ZJJDefaultSelectTableView,ZJJPopupView) { 17 | 18 | return self.tableView(frame: frame, optionModel: optionModel, popupModel: ZJJPopupModel.popup(title: title,animationType: .move), confirmBlock: confirmBlock) 19 | } 20 | @discardableResult 21 | static public func tableView(frame:CGRect = CGRect.init(x: 0, y: 0, width: UIScreen.main.bounds.size.width, height:220),optionModel:ZJJOption,popupModel:ZJJPopupModel = ZJJPopupModel.init(),confirmBlock:ZJJPopupTableViewBlock? = nil) -> (ZJJDefaultSelectTableView,ZJJPopupView){ 22 | let tableView = ZJJDefaultSelectTableView.init(frame: frame, model: optionModel) 23 | let popupView = ZJJPopupView.init(contentView:tableView , popupModel: popupModel) { (popView, btn) in 24 | if let block = confirmBlock { 25 | block(tableView,popView,tableView.selectModel,btn) 26 | } 27 | } cancelBlock: { (popView, btn) in 28 | 29 | } 30 | popupView.show() 31 | return (tableView,popupView) 32 | } 33 | 34 | @discardableResult 35 | static public func pickerView(frame:CGRect = CGRect.init(x: 0, y: 0, width: UIScreen.main.bounds.size.width, height:220),optionModel:ZJJOption,title:String,confirmBlock:ZJJPopupPickerBlock? = nil) -> (ZJJDefaultPickerView,ZJJPopupView) { 36 | 37 | return self.pickerView(frame: frame, optionModel: optionModel, popupModel: ZJJPopupModel.popup(title: title,animationType: .move), confirmBlock: confirmBlock) 38 | } 39 | @discardableResult 40 | static public func pickerView(frame:CGRect = CGRect.init(x: 0, y: 0, width: UIScreen.main.bounds.size.width, height:220),optionModel:ZJJOption,popupModel:ZJJPopupModel = ZJJPopupModel.init(),confirmBlock:ZJJPopupPickerBlock? = nil) -> (ZJJDefaultPickerView,ZJJPopupView){ 41 | let pickerView = ZJJDefaultPickerView.init(frame:frame, model: optionModel) 42 | let popupView = ZJJPopupView.init(contentView:pickerView , popupModel: popupModel) { (popView, btn) in 43 | if let block = confirmBlock { 44 | block(pickerView,popView,pickerView.selectModel,btn) 45 | } 46 | } cancelBlock: { (popView, btn) in 47 | 48 | } 49 | popupView.show() 50 | return (pickerView,popupView) 51 | } 52 | 53 | static public func customView(contentView:UIView,isTouchHidden:Bool = false,animationType:ZJJPopupAnimationType = .scale,blurEffectStyle:ZJJBlurEffectStyle = .none) -> ZJJPopupView{ 54 | var popupModel = ZJJPopupModel() 55 | popupModel.isTouchHidden = isTouchHidden 56 | popupModel.animationType = animationType 57 | popupModel.blurEffectStyle = blurEffectStyle 58 | popupModel.topViewConfig.isHidden = true //隐藏topView 59 | let popupView = ZJJPopupView.init(contentView: contentView, popupModel: popupModel) 60 | popupView.show() 61 | return popupView 62 | } 63 | 64 | static public func customView(contentView:UIView,popupModel:ZJJPopupModel) -> ZJJPopupView{ 65 | let popupView = ZJJPopupView.init(contentView: contentView, popupModel: popupModel) 66 | popupView.show() 67 | return popupView 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /ZJJPopup/ZJJPopup/ZJJPopupModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ZJJPopupModel.swift 3 | // ZJJPopup 4 | // 5 | // Created by weiqu on 2021/4/26. 6 | // 7 | 8 | import UIKit 9 | 10 | struct ZJJPopupModel { 11 | 12 | var animationType:ZJJPopupAnimationType = .move //弹框出现样式 13 | var showInType:ZJJPopupViewShowInType = .window //弹框添加到哪里,默认是在window上 14 | var popupViewRadius:CGFloat = 10 //设置popupView的圆角 15 | var isTouchHidden:Bool = true //点击遮罩层,是否隐藏弹框视图 16 | var isConfirmHidden:Bool = true //点击确定按钮,是否隐藏弹框视图 17 | var contentViewMinHeight:CGFloat = 220 //contentView内容的最小高度 18 | var maskLayerColor:UIColor = UIColor.init(red:0, green: 0, blue:0, alpha: 0.5) //遮罩层的颜色 19 | var blurEffectStyle:ZJJBlurEffectStyle = .none //设置毛玻璃效果,设置为none,显示遮罩层的颜色 20 | var backgroundColor:UIColor = .white{ 21 | didSet{ 22 | self.topViewConfig.backgroundColor = backgroundColor 23 | } 24 | } //背景颜色 25 | 26 | var topViewConfig:ZJJPopupTopViewConfig = ZJJPopupTopViewConfig() //topVie配置 27 | static func popup(title:String,animationType:ZJJPopupAnimationType = .move) -> ZJJPopupModel { 28 | var model = ZJJPopupModel() 29 | model.topViewConfig.titleConfig.text = title 30 | model.animationType = animationType 31 | return model 32 | } 33 | 34 | static func popupCenter(isTouch isTouchHidden:Bool = false,minHeight contentViewMinHeight:CGFloat = 220) -> ZJJPopupModel { 35 | var model = ZJJPopupModel() 36 | model.isTouchHidden = isTouchHidden 37 | model.animationType = .scale 38 | model.contentViewMinHeight = contentViewMinHeight //设置最小高度 39 | model.topViewConfig.isHidden = true //隐藏topView 40 | return model 41 | } 42 | 43 | } 44 | 45 | class ZJJPopupTopViewConfig{ 46 | var isHidden:Bool = false //是否隐藏 47 | var backgroundColor:UIColor = .white 48 | var minHeight:CGFloat = 48 //最小高度 49 | var isTitleAutomaticCenter:Bool = true //标题是否自动居中,true表示title的宽度=supview.width - max(cancel.width ,confirm.width)*2,并且居中显示,fasle 表示 title的宽度=supview.width-(显示按钮的宽度),不一定居中显示 50 | //分割线设置 51 | var separatorConfig:ZJJPopupSeparatorConfig = ZJJPopupSeparatorConfig() 52 | var titleConfig:ZJJPopupUIConfig = ZJJPopupUIConfig() //标题的设置 53 | var cancelConfig:ZJJPopupButtonConfig = ZJJPopupButtonConfig.init(text: "取消") //取消按钮设置 54 | var confirmConfig:ZJJPopupButtonConfig = ZJJPopupButtonConfig.init(text: "确定") //确定按钮设置 55 | init(isHidden:Bool = false,minHeight:CGFloat = 48,isTitleAutomaticCenter:Bool = true) { 56 | self.isHidden = isHidden 57 | self.minHeight = minHeight 58 | self.isTitleAutomaticCenter = isTitleAutomaticCenter 59 | } 60 | } 61 | 62 | class ZJJPopupSeparatorConfig { 63 | var color:UIColor = UIColor(red: 0.42, green: 0.41, blue: 0.47,alpha:0.3) //分割线的颜色 64 | var height:CGFloat = 0.5 //分割线的高度 65 | var isHidden:Bool = false //是否隐藏分割线 66 | } 67 | 68 | class ZJJPopupButtonConfig: ZJJPopupUIConfig { 69 | var margin:CGFloat = 8 //按钮距离父视图的左边或右边距离,如果按钮在左边,那么就是距离父视图的左边距,如果按钮在右边,那么就是距离俯视图的右边距 70 | var maxWidth:CGFloat = 80 //按钮的最大宽度,如果文本过长,超过最大宽度,那么按钮的宽度为maxWidth,会根据numberOfLines属性来计算文本是否换行 71 | var minTopBottom:CGFloat = 8 //按钮距离父视图的上下边的最小边距 72 | open class var halfRadius: CGFloat { 73 | get { 74 | return -1 75 | } 76 | } //圆角等于按钮高度的一半的参数 77 | } 78 | 79 | 80 | class ZJJPopupUIConfig{ 81 | 82 | var text:String = "" 83 | var isHidden:Bool = false 84 | var font:UIFont = .systemFont(ofSize: 16) 85 | var color:UIColor = .black 86 | var numberOfLines:Int = 0 87 | var backgroundColor:UIColor = .clear 88 | var textAlignment:NSTextAlignment = .center 89 | var leftRightMargin:CGFloat = 10 //文本的左右边距 90 | var borderWidth:CGFloat = 0 91 | var borderColor:UIColor = UIColor.clear 92 | var cornerRadius:CGFloat = 0 93 | var masksToBounds:Bool = false 94 | 95 | init(text:String = "") { 96 | self.text = text 97 | } 98 | 99 | func set(cornerRadius:CGFloat = 0,borderWidth:CGFloat = 0,borderColor:UIColor = UIColor.clear) { 100 | self.masksToBounds = true 101 | self.cornerRadius = cornerRadius 102 | self.borderWidth = borderWidth 103 | self.borderColor = borderColor 104 | } 105 | 106 | } 107 | -------------------------------------------------------------------------------- /ZJJPopup/Example/ZJJConfigModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ZJJConfigModel.swift 3 | // ZJJPopup 4 | // 5 | // Created by weiqu on 2021/4/28. 6 | // 7 | 8 | import UIKit 9 | 10 | enum ZJJPopupType:String { 11 | case picker,tableView,customTableView,customView 12 | } 13 | 14 | class ZJJConfigModel { 15 | 16 | var type:ZJJPopupType = .picker 17 | var option:ZJJOption = ZJJOption() 18 | var popupModel:ZJJPopupModel = ZJJPopupModel() 19 | init(type:ZJJPopupType = .picker,option:ZJJOption = ZJJOption(),popupModel:ZJJPopupModel = ZJJPopupModel()) { 20 | self.type = type 21 | self.option = option 22 | self.popupModel = popupModel 23 | } 24 | static func picker() -> ZJJConfigModel { 25 | let option = self.getOption(type: .picker) 26 | return ZJJConfigModel.init(type: .picker, option: option) 27 | } 28 | 29 | static func tableView(title:String = "") -> ZJJConfigModel { 30 | var option = self.getOption(type: .tableView) 31 | //设置默认选择的对象 32 | option.selectModel = option.optionArray[6] 33 | let popupModel = ZJJPopupModel.tableView(title: title) 34 | return ZJJConfigModel.init(type: .tableView, option: option, popupModel: popupModel) 35 | } 36 | 37 | static func customTableView(title:String = "") -> ZJJConfigModel { 38 | 39 | var option = ZJJOption() 40 | //构造数据 41 | for i in 0 ..< 20 { 42 | let data = ZJJCustomModel.init() 43 | data.icon = "dizhic_icon" 44 | data.title = self.getTitle(count: i) 45 | option.optionArray.append(data) 46 | } 47 | 48 | var popupModel = ZJJPopupModel() 49 | // popupModel.backgroundColor = .red 50 | popupModel.showInType = .vc //添加到UIViewController上 51 | //设置标题 52 | popupModel.topViewConfig.titleConfig.text = title 53 | //隐藏取消按钮 54 | popupModel.topViewConfig.cancelConfig.isHidden = true 55 | //设置title的位置是否自动居中 56 | popupModel.topViewConfig.isTitleAutomaticCenter = false 57 | //居中显示 58 | popupModel.animationType = .scale 59 | return ZJJConfigModel.init(type: .customTableView, option: option,popupModel: popupModel) 60 | } 61 | 62 | static func getOption(type:ZJJPopupType) -> ZJJOption{ 63 | var option = ZJJOption() 64 | //构造数据 65 | for i in 0 ..< 15 { 66 | let data = ZJJDataModel.init(title: "\(type.rawValue)", row: i+1) 67 | option.optionArray.append(data) 68 | } 69 | return option 70 | } 71 | 72 | static func getTitle(count:Int) -> String { 73 | var value = "" 74 | for i in 0 ..< count+1 { 75 | value = "test\(i) " + value 76 | } 77 | return value 78 | } 79 | } 80 | 81 | 82 | 83 | extension ZJJPopupModel { 84 | 85 | static func tableView(title:String = "") -> ZJJPopupModel{ 86 | var popupModel = ZJJPopupModel() 87 | popupModel.isTouchHidden = false //点击遮罩层,是否隐藏弹框视图 88 | popupModel.isConfirmHidden = false //点击确定按钮,是否隐藏弹框视图 89 | popupModel.contentViewMinHeight = 300 //contentView内容的最小高度 90 | popupModel.topViewConfig.minHeight = 50 //topView 内容的最小高度 91 | popupModel.popupViewRadius = 0 //设置popupView的圆角 92 | popupModel.maskLayerColor = UIColor.init(red:0, green: 0, blue:0, alpha: 0.8) //遮罩层的颜色 93 | popupModel.showInType = .nc //弹窗添加到navigationController上 94 | popupModel.topViewConfig.backgroundColor = .orange 95 | popupModel.topViewConfig.titleConfig.color = .white 96 | //设置标题 97 | popupModel.topViewConfig.titleConfig.text = title 98 | //设置标题的字体大小 99 | popupModel.topViewConfig.titleConfig.font = UIFont.systemFont(ofSize: 20) 100 | //隐藏取消按钮 101 | popupModel.topViewConfig.cancelConfig.isHidden = true 102 | //设置确定按钮的文本 103 | popupModel.topViewConfig.confirmConfig.text = "Confirm" 104 | //按钮的内文本距离按钮的左右边距 105 | popupModel.topViewConfig.confirmConfig.leftRightMargin = 15 106 | //设置确定文本的颜色 107 | popupModel.topViewConfig.confirmConfig.color = .white 108 | //设置确定按钮的背景色 109 | popupModel.topViewConfig.confirmConfig.backgroundColor = .blue 110 | //设置确定按钮的圆角,边框大小和颜色 111 | popupModel.topViewConfig.confirmConfig.set(cornerRadius: ZJJPopupButtonConfig.halfRadius,borderWidth: 1,borderColor: .red) 112 | return popupModel 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /ZJJPopup/ZJJPopup/ZJJDefaultPickerView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ZJJDefaultPickerView.swift 3 | // ZJJPopup 4 | // 5 | // Created by weiqu on 2021/4/27. 6 | // 7 | 8 | import UIKit 9 | 10 | struct ZJJPickerUI { 11 | var normalColor:UIColor = .black //文本正常颜色 12 | var selectColor:UIColor = .black //文本选择的颜色 13 | var font:UIFont = UIFont.systemFont(ofSize: 17) //字体大小 14 | var leftRightMargin:CGFloat = 20 //文本左右边距 15 | var rowHeight:CGFloat = 40 //行高 16 | var separatorLineColor:UIColor = UIColor(red: 0.42, green: 0.41, blue: 0.47,alpha:0.3) //分割线的颜色 17 | } 18 | 19 | class ZJJDefaultPickerView: UIPickerView { 20 | 21 | private var selectIndex:Int = 0 22 | open var selectModel:ZJJOptionProtocol? 23 | var pickerUI:ZJJPickerUI = ZJJPickerUI(){ 24 | didSet{ 25 | self.reloadComponent(0) 26 | } 27 | } 28 | var model:ZJJOption = ZJJOption() 29 | 30 | init (frame:CGRect,model:ZJJOption,pickerUI:ZJJPickerUI = ZJJPickerUI()){ 31 | super.init(frame: frame) 32 | self.pickerUI = pickerUI 33 | self.initData() 34 | self.model = model 35 | self.reloadPicker(model) 36 | } 37 | 38 | func reloadPicker( _ optionModel:ZJJOption? = nil) { 39 | var model = self.model 40 | if let md = optionModel { 41 | model = md 42 | self.model = model 43 | self.reloadComponent(0) 44 | } 45 | selectIndex = 0 46 | self.selectModel = model.optionArray.first 47 | guard let selectValue = model.selectModel?.jj_optionValue,selectValue.count > 0 else { 48 | self.reloadComponent(0) 49 | return 50 | } 51 | for i in 0 ..< model.optionArray.count { 52 | let item = model.optionArray[i] 53 | if selectValue == item.jj_optionValue { 54 | selectIndex = i 55 | self.selectModel = item 56 | self.selectRow(selectIndex, inComponent: 0, animated: false) 57 | self.reloadComponent(0) 58 | } 59 | } 60 | } 61 | 62 | required init?(coder: NSCoder) { 63 | super.init(coder: coder) 64 | self.initData() 65 | } 66 | 67 | private func initData() { 68 | self.delegate = self 69 | self.dataSource = self 70 | self.showsSelectionIndicator = true 71 | } 72 | 73 | } 74 | 75 | extension ZJJDefaultPickerView:UIPickerViewDataSource,UIPickerViewDelegate{ 76 | 77 | func numberOfComponents(in pickerView: UIPickerView) -> Int { 78 | return 1 79 | } 80 | 81 | func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int { 82 | return self.model.optionArray.count 83 | } 84 | 85 | func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? { 86 | let optionArray = self.model.optionArray 87 | if row < optionArray.count { 88 | if let text = optionArray[row].jj_optionValue { 89 | return text 90 | } 91 | } 92 | return "" 93 | } 94 | 95 | func pickerView(_ pickerView: UIPickerView, widthForComponent component: Int) -> CGFloat { 96 | 97 | return self.frame.size.width 98 | } 99 | 100 | func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) { 101 | let optionArray = self.model.optionArray 102 | if row < optionArray.count { 103 | selectIndex = row 104 | self.selectModel = optionArray[row] 105 | self.reloadComponent(0) 106 | } 107 | } 108 | 109 | func pickerView(_ pickerView: UIPickerView, rowHeightForComponent component: Int) -> CGFloat { 110 | return self.pickerUI.rowHeight 111 | } 112 | 113 | func pickerView(_ pickerView: UIPickerView, viewForRow row: Int, forComponent component: Int, reusing view: UIView?) -> UIView { 114 | 115 | for view in pickerView.subviews { 116 | if view.frame.size.height < 1 { 117 | //设置分割线颜色 118 | view.backgroundColor = pickerUI.separatorLineColor 119 | } 120 | } 121 | 122 | var pickerLabel:UILabel? = nil 123 | 124 | if let label = view as? UILabel { 125 | pickerLabel = label 126 | } 127 | if pickerLabel == nil { 128 | let label = UILabel.init(frame: .init(x: self.pickerUI.leftRightMargin, y:0, width: self.frame.size.width-self.pickerUI.leftRightMargin*2, height: 50)) 129 | label.textAlignment = .center 130 | label.numberOfLines = 2 131 | label.backgroundColor = .clear 132 | label.font = self.pickerUI.font 133 | pickerLabel = label 134 | } 135 | if self.selectIndex == row { 136 | pickerLabel?.textColor = self.pickerUI.selectColor 137 | }else{ 138 | pickerLabel?.textColor = self.pickerUI.normalColor 139 | } 140 | pickerLabel?.text = self.pickerView(pickerView, titleForRow: row, forComponent: component) 141 | return pickerLabel! 142 | } 143 | 144 | 145 | } 146 | -------------------------------------------------------------------------------- /ZJJPopup/Example/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // ZJJPopup 4 | // 5 | // Created by weiqu on 2021/4/28. 6 | // 7 | 8 | import UIKit 9 | 10 | 11 | 12 | class ViewController: UIViewController { 13 | 14 | var dataArray:[ZJJConfigModel] = [] 15 | lazy var tableView:UITableView = { 16 | let tableView = UITableView.init(frame: self.view.bounds, style: .plain) 17 | tableView.delegate = self 18 | tableView.dataSource = self 19 | return tableView 20 | }() 21 | override func viewDidLoad() { 22 | super.viewDidLoad() 23 | self.view.addSubview(self.tableView) 24 | self.dataArray = [ZJJConfigModel.picker(),ZJJConfigModel.tableView(title: "请选择tableView列表中的数据"),ZJJConfigModel.customTableView(title:"请选择customTableView列表中的数据"),ZJJConfigModel.init(type: .customView)] 25 | self.tableView.reloadData() 26 | 27 | // Do any additional setup after loading the view. 28 | } 29 | 30 | func showPicker(model:ZJJConfigModel) { 31 | let (pickerView,_) = ZJJPopup.pickerView(optionModel: model.option, title: "请选择") { (pickerView, popupView, dataModel, btn) in 32 | if let md = dataModel as? ZJJDataModel { 33 | model.option.selectModel = md 34 | self.title = md.jj_optionValue 35 | print("==\(md.title ?? "")==row:\(md.row ?? 0)==") 36 | } 37 | 38 | } 39 | 40 | var pickerUI = ZJJPickerUI() 41 | //设置行高 42 | pickerUI.rowHeight = 44 43 | //设置选择字体的颜色 44 | pickerUI.selectColor = .blue 45 | //字体的大小 46 | pickerUI.font = UIFont.systemFont(ofSize: 20) 47 | //分割线的颜色 48 | pickerUI.separatorLineColor = .red 49 | pickerView.pickerUI = pickerUI 50 | } 51 | 52 | func showTableView(model:ZJJConfigModel) { 53 | 54 | ZJJPopup.tableView(optionModel: model.option, popupModel: model.popupModel) { (tableView, popupView, dataModel, btn) in 55 | btn.isEnabled = false 56 | DispatchQueue.main.asyncAfter(deadline: .now()+0.5) { 57 | //延时,模拟网络请求,等数据成功后在进行隐藏 58 | btn.isEnabled = true 59 | popupView.hidden() 60 | if let md = dataModel as? ZJJDataModel { 61 | model.option.selectModel = md 62 | self.title = md.jj_optionValue 63 | } 64 | } 65 | } 66 | } 67 | 68 | func showCustomTableView(model:ZJJConfigModel) { 69 | 70 | let (tableView,_) = ZJJPopup.tableView(frame: CGRect.init(x: 0, y: 0, width: UIScreen.main.bounds.width-60, height:250), optionModel:model.option, popupModel: model.popupModel) { (tableView, popupView, customModel, btn) in 71 | if let md = customModel as? ZJJCustomModel { 72 | 73 | model.option.selectModel = md 74 | self.title = md.jj_optionValue 75 | print("选中:\(md.jj_optionValue ?? "")") 76 | }else{ 77 | print("未选择") 78 | } 79 | } 80 | tableView.register(UINib.init(nibName: "ZJJCustomCell", bundle: nil), forCellReuseIdentifier: "ZJJCustomCell") 81 | 82 | tableView.setupBlock { (tableView, indexPath, model) -> CGFloat? in 83 | //设置行高 84 | return UITableView.automaticDimension 85 | } cellForRowBlock: { (tableView, indexPath, model, selectModel) -> UITableViewCell? in 86 | //自定义cell 87 | let cell = tableView.dequeueReusableCell(withIdentifier: "ZJJCustomCell", for: indexPath) as! ZJJCustomCell 88 | cell.selectionStyle = .none 89 | if let customModel = model as? ZJJCustomModel { 90 | cell.model = customModel 91 | 92 | if cell.model.jj_optionValue == selectModel?.jj_optionValue { 93 | cell.selectImageView.image = UIImage.init(named: "chengong_icon") 94 | }else{ 95 | cell.selectImageView.image = UIImage.init(named: "weix_icon") 96 | } 97 | } 98 | return cell 99 | } 100 | 101 | } 102 | 103 | func showCustomView(model:ZJJConfigModel) { 104 | 105 | let customView = Bundle.main.loadNibNamed("ZJJCustomView", owner: nil, options: nil)?.first as! ZJJCustomView 106 | customView.frame = CGRect.init(x: 0, y: 0, width: UIScreen.main.bounds.width-80, height: 200) 107 | customView.backgroundColor = .orange 108 | 109 | let popupView = ZJJPopup.customView(contentView: customView,blurEffectStyle: .light) 110 | customView.close { [weak popupView] in 111 | popupView?.hidden() 112 | } 113 | } 114 | 115 | } 116 | 117 | 118 | extension ViewController:UITableViewDelegate,UITableViewDataSource{ 119 | 120 | func numberOfSections(in tableView: UITableView) -> Int { 121 | return 1 122 | } 123 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 124 | return self.dataArray.count 125 | } 126 | 127 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 128 | let cellId = "cellIdentifier" 129 | var cell = tableView.dequeueReusableCell(withIdentifier: cellId) 130 | if cell == nil { 131 | cell = UITableViewCell.init(style: .default, reuseIdentifier: cellId) 132 | 133 | } 134 | let model = self.dataArray[indexPath.row] 135 | cell?.textLabel?.text = model.type.rawValue 136 | // cell?.textLabel?.textColor = .red 137 | cell?.selectionStyle = .none 138 | return cell! 139 | } 140 | 141 | func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { 142 | return 44 143 | } 144 | 145 | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 146 | let model = self.dataArray[indexPath.row] 147 | if model.type == .picker { 148 | self.showPicker(model: model) 149 | } else if model.type == .tableView{ 150 | self.showTableView(model: model) 151 | } else if model.type == .customTableView{ 152 | self.showCustomTableView(model: model) 153 | } else { 154 | self.showCustomView(model: model) 155 | } 156 | } 157 | func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { 158 | return 0.001 159 | } 160 | 161 | func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { 162 | return 0.001 163 | } 164 | 165 | 166 | 167 | } 168 | -------------------------------------------------------------------------------- /ZJJPopup/Example/ZJJCustomCell.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /ZJJPopup/ZJJPopup/ZJJDefaultSelectTableView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ZJJDefaultSelectTableView.swift 3 | // ZJJPopup 4 | // 5 | // Created by weiqu on 2021/4/28. 6 | // 7 | 8 | import UIKit 9 | 10 | typealias ZJJDefaultSelectTableViewCellForRowBlock = (ZJJDefaultSelectTableView,IndexPath,ZJJOptionProtocol,ZJJOptionProtocol?) -> UITableViewCell? 11 | 12 | typealias ZJJDefaultSelectTableViewHeightForRowBlock = (ZJJDefaultSelectTableView,IndexPath,ZJJOptionProtocol) -> CGFloat? 13 | 14 | typealias ZJJDefaultSelectTableViewDidSelectRowAtBlock = (ZJJDefaultSelectTableView,IndexPath,ZJJOptionProtocol) -> () 15 | 16 | 17 | class ZJJDefaultSelectTableView: UITableView { 18 | 19 | private var selectIndex:Int = -1 20 | open var selectModel:ZJJOptionProtocol? 21 | var separatorLeftRightMargin:CGFloat = 15{ 22 | didSet{ 23 | self.separatorInset = UIEdgeInsets.init(top: 0, left: separatorLeftRightMargin, bottom: 0, right: separatorLeftRightMargin) 24 | } 25 | } 26 | private var cellForRowBlock:ZJJDefaultSelectTableViewCellForRowBlock? 27 | private var heightForRowBlock:ZJJDefaultSelectTableViewHeightForRowBlock? 28 | private var didSelectRowAtBlock: ZJJDefaultSelectTableViewDidSelectRowAtBlock? 29 | var model:ZJJOption = ZJJOption(){ 30 | didSet{ 31 | self.reloadData() 32 | } 33 | } 34 | 35 | convenience init(frame: CGRect, model:ZJJOption) { 36 | self.init(frame: frame, style: .plain) 37 | self.model = model 38 | self.reloadSelectTabelView() 39 | } 40 | 41 | override init(frame: CGRect, style: UITableView.Style) { 42 | super.init(frame: frame, style: style) 43 | self.initSelectTableView() 44 | } 45 | 46 | func reloadSelectTabelView( _ optionModel:ZJJOption? = nil) { 47 | var model = self.model 48 | if let md = optionModel { 49 | model = md 50 | self.model = md 51 | } 52 | selectIndex = -1 53 | guard let selectValue = model.selectModel?.jj_optionValue,selectValue.count > 0 else { 54 | self.reloadData() 55 | return 56 | } 57 | self.reloadData() 58 | for i in 0 ..< model.optionArray.count { 59 | let item = model.optionArray[i] 60 | if selectValue == item.jj_optionValue { 61 | selectIndex = i 62 | self.selectModel = item 63 | let indexPath = IndexPath.init(row: i, section: 0) 64 | //需要做延时,才能滑动到准确的位置 65 | DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { 66 | self.scrollToRow(at: indexPath, at: .middle, animated: false) 67 | } 68 | 69 | } 70 | } 71 | } 72 | 73 | required init?(coder: NSCoder) { 74 | super.init(coder: coder) 75 | self.initSelectTableView() 76 | } 77 | 78 | private func initSelectTableView() { 79 | self.delegate = self 80 | self.dataSource = self 81 | self.backgroundColor = .white 82 | self.estimatedRowHeight = 100 83 | self.estimatedSectionHeaderHeight = 0.01 84 | self.estimatedSectionFooterHeight = 0.01 85 | self.separatorColor = .clear 86 | self.separatorLeftRightMargin = 15 87 | } 88 | 89 | 90 | func setupBlock(heightForRowBlock:ZJJDefaultSelectTableViewHeightForRowBlock?,cellForRowBlock:ZJJDefaultSelectTableViewCellForRowBlock?) { 91 | self.heightForRowBlock = heightForRowBlock 92 | self.cellForRowBlock = cellForRowBlock 93 | } 94 | 95 | func setDidSelectRowAtBlock(didSelectRowAtBlock:ZJJDefaultSelectTableViewDidSelectRowAtBlock?) { 96 | self.didSelectRowAtBlock = didSelectRowAtBlock 97 | } 98 | 99 | } 100 | 101 | 102 | 103 | extension ZJJDefaultSelectTableView:UITableViewDataSource,UITableViewDelegate{ 104 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 105 | return self.model.optionArray.count 106 | } 107 | 108 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 109 | let model = self.model.optionArray[indexPath.row] 110 | 111 | if let cellForRowBlock = self.cellForRowBlock { 112 | if let cell = cellForRowBlock(self,indexPath,model,selectModel) { 113 | return cell 114 | } 115 | } 116 | 117 | let cellId = "ZJJDefaultSelectTableViewCellIdentifier" 118 | 119 | var cell = tableView.dequeueReusableCell(withIdentifier: cellId) as? ZJJDefaultSelectTableViewCell 120 | 121 | if cell == nil { 122 | cell = ZJJDefaultSelectTableViewCell.init(style: .default, reuseIdentifier: cellId) 123 | cell?.separatorLeftRightMargin = self.separatorLeftRightMargin 124 | } 125 | cell?.textLabel?.text = model.jj_optionValue 126 | cell?.textLabel?.numberOfLines = 0 127 | cell?.selectionStyle = .none 128 | if selectIndex == indexPath.row { 129 | cell?.accessoryType = .checkmark 130 | }else{ 131 | cell?.accessoryType = .none 132 | } 133 | return cell! 134 | } 135 | 136 | func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { 137 | let model = self.model.optionArray[indexPath.row] 138 | if let heightForRowBlock = self.heightForRowBlock { 139 | 140 | if let height = heightForRowBlock(self,indexPath,model) { 141 | return height 142 | } 143 | } 144 | return UITableView.automaticDimension 145 | } 146 | 147 | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 148 | let model = self.model.optionArray[indexPath.row] 149 | if let block = self.didSelectRowAtBlock { 150 | block(self,indexPath,model) 151 | return 152 | } 153 | self.selectIndex = indexPath.row 154 | self.selectModel = model 155 | self.reloadData() 156 | } 157 | 158 | func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { 159 | return 0.001 160 | } 161 | 162 | func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { 163 | return 0.001 164 | } 165 | 166 | } 167 | 168 | 169 | fileprivate class ZJJDefaultSelectTableViewCell: UITableViewCell { 170 | 171 | private let lineView = UIView.init() 172 | var separatorLeftRightMargin:CGFloat = 15{ 173 | didSet{ 174 | self.setupLineViewFrame() 175 | } 176 | } 177 | override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { 178 | super.init(style: style, reuseIdentifier: reuseIdentifier) 179 | self.initUI() 180 | } 181 | 182 | required init?(coder: NSCoder) { 183 | super.init(coder: coder) 184 | self.initUI() 185 | } 186 | func initUI() { 187 | self.addSubview(self.lineView) 188 | self.lineView.backgroundColor = UIColor(red: 0.42, green: 0.41, blue: 0.47,alpha:0.3) 189 | } 190 | 191 | override func layoutSubviews() { 192 | super.layoutSubviews() 193 | self.setupLineViewFrame() 194 | } 195 | 196 | func setupLineViewFrame() { 197 | self.lineView.frame = CGRect.init(x: separatorLeftRightMargin, y: self.frame.size.height-0.5, width: self.frame.size.width-separatorLeftRightMargin*2, height: 0.5) 198 | } 199 | } 200 | -------------------------------------------------------------------------------- /ZJJPopup/ZJJPopup/ZJJPopupTopView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ZJJPopupTopView.swift 3 | // ZJJPopup 4 | // 5 | // Created by weiqu on 2021/4/27. 6 | // 7 | 8 | import UIKit 9 | 10 | typealias ZJJPopupTopViewButtonBlock = (UIButton) -> () 11 | 12 | class ZJJPopupTopView: UIView { 13 | 14 | private let titleLabel = UILabel() 15 | private let lineView:UIView = UIView() 16 | public let cancelButton = UIButton() 17 | public let confirmButton = UIButton() 18 | private var cancelButtonBlock:ZJJPopupTopViewButtonBlock? 19 | private var confirmButtonBlock:ZJJPopupTopViewButtonBlock? 20 | private var config:ZJJPopupTopViewConfig = ZJJPopupTopViewConfig() 21 | 22 | 23 | 24 | init(frame: CGRect = .zero,config:ZJJPopupTopViewConfig = ZJJPopupTopViewConfig()) { 25 | super.init(frame: frame) 26 | self.setup(frame: frame, config: config) 27 | } 28 | required init?(coder: NSCoder) { 29 | fatalError("init(coder:) has not been implemented") 30 | } 31 | 32 | public func setup(frame:CGRect,config:ZJJPopupTopViewConfig) { 33 | var selfFrame = frame 34 | if frame.size.width < 1 { 35 | selfFrame.size.width = UIScreen.main.bounds.width 36 | } 37 | self.frame = selfFrame 38 | confirmButton.contentEdgeInsets = .init(top: 0, left: 15, bottom: 0, right: 15) 39 | self.config = config 40 | self.cancelButton.addTarget(self, action: #selector(cancelButtonClick(btn:)), for: .touchUpInside) 41 | self.confirmButton.addTarget(self, action: #selector(confirmButtonClick(btn:)), for: .touchUpInside) 42 | self.setupUI() 43 | } 44 | 45 | func clickCancelButton(block:ZJJPopupTopViewButtonBlock?) { 46 | self.cancelButtonBlock = block 47 | } 48 | 49 | func clickConfirmButton(block:ZJJPopupTopViewButtonBlock?) { 50 | self.confirmButtonBlock = block 51 | } 52 | 53 | private func setupUI() { 54 | 55 | var cancelSize = CGSize.zero 56 | var confirmSize = CGSize.zero 57 | var titleWidth:CGFloat = 0 58 | var titleHeight:CGFloat = 0 59 | self.backgroundColor = config.backgroundColor 60 | if !config.cancelConfig.isHidden { 61 | self.addSubview(self.cancelButton) 62 | cancelButton.contentEdgeInsets = .init(top: 0, left: config.cancelConfig.leftRightMargin, bottom: 0, right: config.cancelConfig.leftRightMargin) 63 | self.setup(view: cancelButton, config: config.cancelConfig) 64 | cancelSize = self.getBtnSize(config: config.cancelConfig) 65 | if config.cancelConfig.cornerRadius == ZJJPopupButtonConfig.halfRadius { 66 | cancelButton.layer.cornerRadius = cancelSize.height/2.0 67 | } 68 | } 69 | 70 | if !config.confirmConfig.isHidden { 71 | self.addSubview(self.confirmButton) 72 | confirmButton.contentEdgeInsets = .init(top: 0, left: config.confirmConfig.leftRightMargin, bottom: 0, right: config.confirmConfig.leftRightMargin) 73 | self.setup(view: confirmButton, config: config.confirmConfig) 74 | confirmSize = self.getBtnSize(config: config.confirmConfig) 75 | if config.confirmConfig.cornerRadius == ZJJPopupButtonConfig.halfRadius { 76 | confirmButton.layer.cornerRadius = confirmSize.height/2.0 77 | } 78 | } 79 | 80 | if !config.titleConfig.isHidden { 81 | 82 | self.addSubview(self.titleLabel) 83 | self.setup(view: titleLabel, config: config.titleConfig) 84 | titleWidth = self.getTitleWidth(cancelSize: cancelSize, confirmSize: confirmSize) 85 | 86 | if titleWidth > 0 { 87 | let height = self.getHeight(width: titleWidth, config: config.titleConfig) 88 | if config.titleConfig.numberOfLines == 0 { 89 | titleHeight = height 90 | }else if config.titleConfig.numberOfLines > 1{ 91 | let heightN = CGFloat(22*config.titleConfig.numberOfLines)+10 92 | if height > heightN { 93 | titleHeight = heightN 94 | }else{ 95 | titleHeight = height 96 | } 97 | 98 | }else{ 99 | titleHeight = 30 100 | } 101 | 102 | } 103 | } 104 | 105 | 106 | //取最大值作为topView的高度 107 | let viewHeight = max(cancelSize.height+config.cancelConfig.minTopBottom*2, confirmSize.height+config.confirmConfig.minTopBottom*2, titleHeight, config.minHeight) 108 | 109 | var selfFrame = self.frame 110 | selfFrame.size.height = viewHeight 111 | self.frame = selfFrame 112 | 113 | self.cancelButton.frame = CGRect.init(origin: CGPoint.init(x: config.cancelConfig.margin, y: 0), size: cancelSize) 114 | self.cancelButton.center = CGPoint.init(x:self.cancelButton.center.x , y: viewHeight/2.0) 115 | self.confirmButton.frame = CGRect.init(origin: CGPoint.init(x: self.frame.size.width - config.confirmConfig.margin-confirmSize.width, y: 0), size: confirmSize) 116 | self.confirmButton.center = CGPoint.init(x:self.confirmButton.center.x , y: viewHeight/2.0) 117 | 118 | self.setupTitleFrame(width: titleWidth, height: titleHeight, viewHeight: viewHeight) 119 | 120 | if !config.separatorConfig.isHidden { 121 | self.addSubview(self.lineView) 122 | self.lineView.backgroundColor = config.separatorConfig.color 123 | self.lineView.frame = CGRect.init(x: 0, y: viewHeight-config.separatorConfig.height, width: self.frame.size.width, height:config.separatorConfig.height) 124 | } 125 | 126 | 127 | } 128 | 129 | private func getTitleWidth(cancelSize:CGSize,confirmSize:CGSize) -> CGFloat{ 130 | let titleWidth:CGFloat = self.frame.size.width - config.titleConfig.leftRightMargin*2 - config.cancelConfig.margin-config.confirmConfig.margin 131 | if !config.isTitleAutomaticCenter { 132 | 133 | if config.cancelConfig.isHidden && !config.confirmConfig.isHidden { 134 | //取消按钮是隐藏,但确定按钮不隐藏 135 | return titleWidth - confirmSize.width 136 | } 137 | if config.confirmConfig.isHidden && !config.cancelConfig.isHidden { 138 | //取消按钮显示,确定按钮隐藏 139 | return titleWidth - cancelSize.width 140 | } 141 | } 142 | 143 | return titleWidth - max(cancelSize.width, confirmSize.width)*2 144 | } 145 | 146 | private func setupTitleFrame(width:CGFloat,height:CGFloat,viewHeight:CGFloat){ 147 | if !config.isTitleAutomaticCenter { 148 | 149 | if config.cancelConfig.isHidden && !config.confirmConfig.isHidden { 150 | //取消按钮是隐藏,但确定按钮显示 151 | self.titleLabel.frame = CGRect.init(x: config.cancelConfig.margin + config.titleConfig.leftRightMargin, y: 0, width: width, height: viewHeight) 152 | self.titleLabel.center = CGPoint.init(x: self.titleLabel.center.x, y: viewHeight/2.0) 153 | return 154 | } 155 | if config.confirmConfig.isHidden && !config.cancelConfig.isHidden { 156 | //取消按钮显示,确定按钮隐藏 157 | self.titleLabel.frame = CGRect.init(x: config.cancelConfig.margin + config.titleConfig.leftRightMargin + self.cancelButton.frame.size.width, y: 0, width: width, height: height) 158 | self.titleLabel.center = CGPoint.init(x: self.titleLabel.center.x, y: viewHeight/2.0) 159 | return 160 | } 161 | } 162 | self.titleLabel.frame = CGRect.init(x: 0, y: 0, width: width, height: height) 163 | self.titleLabel.center = CGPoint.init(x: self.frame.size.width/2.0, y: viewHeight/2.0) 164 | 165 | } 166 | 167 | private func getBtnSize(config:ZJJPopupButtonConfig) -> CGSize { 168 | if !config.isHidden { 169 | let maxWidth:CGFloat = config.maxWidth 170 | //文本内容距离按钮的左右边距 171 | let buttonEdgeInsetLeftRight = config.leftRightMargin 172 | let width = config.text.boundingRect(with: CGSize.init(width: CGFloat(MAXFLOAT), height: 25), options: .usesLineFragmentOrigin, attributes: [NSAttributedString.Key.font:config.font], context: nil).size.width 173 | let btnHeight = self.config.minHeight - config.minTopBottom*2 174 | 175 | if width > maxWidth { 176 | //文本的宽度大于最大宽度 177 | //按钮的宽度 178 | let btnWidth = maxWidth+buttonEdgeInsetLeftRight*2 179 | if config.numberOfLines == 0 { 180 | return CGSize.init(width: btnWidth, height: self.getHeight(width: maxWidth, config: config)) 181 | }else if config.numberOfLines > 1{ 182 | return CGSize.init(width: btnWidth, height: btnHeight*CGFloat(config.numberOfLines)*5/6) 183 | } 184 | return CGSize.init(width: btnWidth, height: btnHeight) 185 | }else{ 186 | return CGSize.init(width: width+buttonEdgeInsetLeftRight*2, height: btnHeight) 187 | } 188 | 189 | } 190 | return CGSize.zero 191 | } 192 | //计算文本的高度 193 | private func getHeight(width:CGFloat,config:ZJJPopupUIConfig) -> CGFloat { 194 | if !config.isHidden { 195 | let height = config.text.boundingRect(with: CGSize.init(width: width, height: CGFloat(MAXFLOAT)), options: .usesLineFragmentOrigin, attributes: [NSAttributedString.Key.font:config.font], context: nil).size.height 196 | return height + 20 197 | } 198 | return 0 199 | } 200 | 201 | private func setup(view:UIView,config:ZJJPopupUIConfig) { 202 | 203 | if let btn = view as? UIButton { 204 | btn.titleLabel?.font = config.font 205 | btn.titleLabel?.numberOfLines = config.numberOfLines 206 | btn.setTitle(config.text, for: .normal) 207 | btn.setTitle(config.text, for: .highlighted) 208 | btn.setTitleColor(config.color, for: .normal) 209 | btn.setTitleColor(config.color, for: .highlighted) 210 | } else if let label = view as? UILabel { 211 | 212 | label.font = config.font 213 | label.text = config.text 214 | label.textColor = config.color 215 | label.numberOfLines = config.numberOfLines 216 | label.textAlignment = config.textAlignment 217 | } 218 | view.backgroundColor = config.backgroundColor 219 | 220 | if config.masksToBounds { 221 | view.layer.masksToBounds = config.masksToBounds 222 | view.layer.borderWidth = config.borderWidth 223 | view.layer.borderColor = config.borderColor.cgColor 224 | view.layer.cornerRadius = config.cornerRadius 225 | } 226 | } 227 | 228 | @objc private func cancelButtonClick(btn:UIButton){ 229 | if let block = self.cancelButtonBlock { 230 | block(btn) 231 | } 232 | } 233 | 234 | @objc private func confirmButtonClick(btn:UIButton){ 235 | if let block = self.confirmButtonBlock { 236 | block(btn) 237 | } 238 | } 239 | 240 | } 241 | -------------------------------------------------------------------------------- /ZJJPopup/ZJJPopup/ZJJPopupView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ZJJPopupView.swift 3 | // ZJJPopup 4 | // 5 | // Created by weiqu on 2021/4/26. 6 | // 7 | 8 | import UIKit 9 | 10 | 11 | typealias ZJJPopupViewBlock = (ZJJPopupView,UIButton) -> () 12 | 13 | public enum ZJJPopupViewShowInType{ 14 | case window //添加到window上 15 | case vc //添加到当前的UIViewController上 16 | case nc //添加到UINavigationController上 17 | } 18 | 19 | public enum ZJJBlurEffectStyle:Int{ 20 | case none = -1 21 | case extraLight = 0 22 | case light = 1 23 | case dark = 2 24 | } 25 | 26 | public enum ZJJPopupAnimationType { 27 | case move 28 | case scale 29 | case fade 30 | } 31 | 32 | class ZJJPopupView: UIView,UIGestureRecognizerDelegate { 33 | 34 | private let popupView = UIView() 35 | private var model:ZJJPopupModel = ZJJPopupModel() 36 | private var topView:ZJJPopupTopView = ZJJPopupTopView() 37 | private var contentView:UIView = UIView() 38 | private var confirmBlock:ZJJPopupViewBlock? 39 | private var cancelBlock:ZJJPopupViewBlock? 40 | private var animationType:ZJJPopupAnimationType = .move 41 | private var isAnimation:Bool = false //是否正在进行显示或消失的动画 42 | private var jj_window:UIWindow? 43 | private var jj_showInView:UIView? 44 | private var effectView: UIVisualEffectView? 45 | convenience init(contentView:UIView,popupModel:ZJJPopupModel = ZJJPopupModel(),confirmBlock: ZJJPopupViewBlock? = nil){ 46 | self.init(contentView:contentView,popupModel:popupModel,confirmBlock: confirmBlock,cancelBlock: nil) 47 | } 48 | 49 | init(contentView:UIView,popupModel:ZJJPopupModel,confirmBlock: ZJJPopupViewBlock? = nil,cancelBlock: ZJJPopupViewBlock? = nil) { 50 | super.init(frame: .zero) 51 | self.jj_window = UIWindow.current() 52 | self.model = popupModel 53 | self.animationType = popupModel.animationType 54 | self.showInView() 55 | self.frame = CGRect.init(x: 0, y: 0, width: self.getViewWidth(), height: self.getViewHeight()) 56 | 57 | self.contentView = contentView 58 | if model.isTouchHidden { 59 | let tap = UITapGestureRecognizer.init(target: self, action: #selector(hidden)) 60 | tap.delegate = self 61 | self.addGestureRecognizer(tap) 62 | } 63 | if !model.topViewConfig.isHidden { 64 | self.setupTopView() 65 | self.confirmBlock = confirmBlock 66 | self.cancelBlock = cancelBlock 67 | } 68 | 69 | self.setupUI() 70 | 71 | 72 | } 73 | 74 | private func showInView(){ 75 | if let window = self.jj_window { 76 | if model.showInType == .window { 77 | window.addSubview(self) 78 | return 79 | }else if model.showInType == .vc{ 80 | if let vc = window.currentVC() { 81 | self.jj_showInView = vc.view 82 | vc.view.addSubview(self) 83 | return 84 | } 85 | }else if model.showInType == .nc{ 86 | if let nc = window.currentVC()?.navigationController { 87 | self.jj_showInView = nc.view 88 | nc.view.addSubview(self) 89 | return 90 | } 91 | } 92 | 93 | } 94 | } 95 | 96 | private func setupTopView() { 97 | 98 | var contentViewWidth = contentView.frame.size.width 99 | if contentViewWidth < 1 { 100 | contentViewWidth = self.getViewWidth() 101 | } 102 | self.topView.setup(frame: CGRect.init(x: 0, y: 0, width:contentViewWidth, height:0), config: model.topViewConfig) 103 | self.topView.clickCancelButton { [weak self](btn) in 104 | guard let weakSelf = self else {return} 105 | weakSelf.hidden() 106 | if let cancelBlock = weakSelf.cancelBlock{ 107 | cancelBlock(weakSelf,btn) 108 | } 109 | } 110 | self.topView.clickConfirmButton { [weak self](btn) in 111 | guard let weakSelf = self else {return} 112 | if weakSelf.model.isConfirmHidden { 113 | weakSelf.hidden() 114 | } 115 | if let confirmBlock = weakSelf.confirmBlock{ 116 | confirmBlock(weakSelf,btn) 117 | } 118 | } 119 | 120 | } 121 | 122 | 123 | open func show() { 124 | if self.isAnimation { 125 | return 126 | } 127 | self.effectView?.removeFromSuperview() 128 | self.effectView = nil 129 | if self.model.blurEffectStyle == .none { 130 | self.backgroundColor = self.model.maskLayerColor 131 | }else{ 132 | if let style = UIBlurEffect.Style.init(rawValue: self.model.blurEffectStyle.rawValue) { 133 | self.effectView = UIVisualEffectView.init(effect: UIBlurEffect.init(style: style)) 134 | self.effectView?.alpha = 0.85 135 | self.effectView?.frame = bounds 136 | self.insertSubview(self.effectView!, at: 0) 137 | }else{ 138 | self.backgroundColor = self.model.maskLayerColor 139 | } 140 | } 141 | self.alpha = 0 142 | if animationType == .scale { 143 | self.popupView.transform = CGAffineTransform.init(scaleX: 0, y: 0) 144 | }else if animationType == .move{ 145 | self.popupView.transform = CGAffineTransform(translationX: 0, y: self.getViewHeight()) 146 | }else{ 147 | self.popupView.alpha = 0 148 | } 149 | self.animate(animations: { [weak self] in 150 | guard let weakSelf = self else {return} 151 | if weakSelf.animationType == .fade{ 152 | self?.popupView.alpha = 1 153 | }else{ 154 | weakSelf.popupView.transform = .identity 155 | } 156 | weakSelf.alpha = 1 157 | }, completion:nil) 158 | } 159 | 160 | @objc open func hidden() { 161 | if self.isAnimation { 162 | return 163 | } 164 | self.animate { [weak self] in 165 | guard let weakSelf = self else {return} 166 | if weakSelf.animationType == .move{ 167 | weakSelf.popupView.transform = CGAffineTransform(translationX: 0, y: weakSelf.getViewHeight()) 168 | }else{ 169 | weakSelf.popupView.isHidden = true 170 | } 171 | weakSelf.alpha = 0 172 | } completion: { [weak self] in 173 | self?.removeFromSuperview() 174 | } 175 | 176 | } 177 | 178 | 179 | private func animate(animations: @escaping () -> Void, completion:(() -> Void)? = nil){ 180 | self.isAnimation = true 181 | let usingSpringWithDamping:CGFloat = 0.8 182 | let initialSpringVelocity:CGFloat = 0.5 183 | let duration:Double = 0.3 184 | UIView.animate(withDuration: duration, delay: 0, usingSpringWithDamping: usingSpringWithDamping, initialSpringVelocity: initialSpringVelocity, options: .curveEaseInOut, animations: animations) { (_) in 185 | self.isAnimation = false 186 | if let cm = completion { 187 | cm() 188 | } 189 | } 190 | } 191 | 192 | private func setupUI() { 193 | self.addSubview(self.popupView) 194 | self.backgroundColor = .clear 195 | self.popupView.backgroundColor = .clear 196 | if self.contentView.backgroundColor == nil || self.contentView.backgroundColor == .clear { 197 | self.contentView.backgroundColor = model.backgroundColor 198 | } 199 | self.popupView.backgroundColor = model.backgroundColor 200 | self.popupView.addSubview(self.contentView) 201 | 202 | let contentViewHeight = max(contentView.frame.size.height, model.contentViewMinHeight) 203 | var topViewViewHeight:CGFloat = 0 204 | var popuViewWidth:CGFloat = self.contentView.frame.size.width 205 | if !model.topViewConfig.isHidden { 206 | topViewViewHeight = max(topView.frame.size.height, model.topViewConfig.minHeight) 207 | popuViewWidth = self.topView.frame.size.width 208 | self.popupView.addSubview(self.topView) 209 | }else{ 210 | if popuViewWidth < 1 { 211 | popuViewWidth = self.getViewWidth() 212 | } 213 | } 214 | 215 | let popupViewHeight:CGFloat = contentViewHeight + topViewViewHeight 216 | self.popupView.frame = CGRect.init(x: 0, y: self.getViewHeight()-popupViewHeight, width:popuViewWidth, height: popupViewHeight) 217 | if animationType == .move { 218 | self.popupView.center = CGPoint.init(x: self.getViewWidth()/2.0, y: self.popupView.center.y) 219 | 220 | }else{ 221 | self.popupView.center = CGPoint.init(x: self.getViewWidth()/2.0, y: self.getViewHeight()/2.0) 222 | } 223 | 224 | self.contentView.frame = CGRect.init(x: 0, y: topViewViewHeight-1, width: popuViewWidth, height:contentViewHeight+1) 225 | self.contentView.center = CGPoint.init(x: self.popupView.frame.size.width/2.0, y: self.contentView.center.y) 226 | //设置圆角 227 | self.setCornersRadius() 228 | 229 | } 230 | 231 | private func setCornersRadius(){ 232 | let radius = model.popupViewRadius 233 | if radius > 0 { 234 | if model.animationType == .move { 235 | self.popupView.jj_setCornersRadius(radius: radius, roundingCorners: [.topLeft,.topRight]) 236 | }else{ 237 | self.popupView.jj_setCornersRadius(radius: radius, roundingCorners: [.allCorners]) 238 | } 239 | } 240 | } 241 | 242 | required init?(coder: NSCoder) { 243 | fatalError("init(coder:) has not been implemented") 244 | } 245 | 246 | 247 | 248 | func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool { 249 | guard let touchView = touch.view else { 250 | return model.isTouchHidden 251 | } 252 | //touchView的frame转化到popupView上的frame 253 | let frame = touchView.convert(touchView.frame, to: self.popupView) 254 | if frame.origin.x >= 0&&frame.origin.y >= 0 { 255 | //说明点击的是popupView上的视图 256 | return false 257 | } 258 | return model.isTouchHidden 259 | } 260 | 261 | private func getViewHeight() -> CGFloat { 262 | if let view = self.jj_showInView { 263 | return view.bounds.height 264 | } 265 | return UIScreen.main.bounds.height 266 | } 267 | 268 | private func getViewWidth() -> CGFloat { 269 | if let view = self.jj_showInView { 270 | return view.bounds.width 271 | } 272 | return UIScreen.main.bounds.width 273 | } 274 | 275 | } 276 | 277 | 278 | extension UIView { 279 | //设置圆角 280 | func jj_setCornersRadius(radius: CGFloat, roundingCorners: UIRectCorner) { 281 | 282 | let maskPath = UIBezierPath(roundedRect: self.bounds, byRoundingCorners: roundingCorners, cornerRadii: CGSize(width: radius, height: radius)) 283 | let maskLayer = CAShapeLayer() 284 | maskLayer.frame = self.bounds 285 | maskLayer.path = maskPath.cgPath 286 | maskLayer.shouldRasterize = true 287 | maskLayer.rasterizationScale = UIScreen.main.scale 288 | self.layer.mask = maskLayer 289 | } 290 | 291 | } 292 | 293 | extension UIWindow { 294 | 295 | static func current() -> UIWindow? { 296 | if #available(iOS 13, *) { 297 | for scene in UIApplication.shared.connectedScenes { 298 | if scene.activationState == .foregroundActive,let window = (scene as! UIWindowScene).windows.first { 299 | return window 300 | } 301 | } 302 | if UIApplication.shared.windows.count > 0 { 303 | for window in UIApplication.shared.windows { 304 | if window.isMember(of: UIWindow.self) { 305 | return window 306 | } 307 | } 308 | } 309 | }else{ 310 | if let delegate = UIApplication.shared.delegate,let window = delegate.window,let w = window { 311 | return w 312 | } 313 | } 314 | return nil 315 | } 316 | 317 | func currentVC() -> UIViewController?{ 318 | if let rootVC = self.rootViewController{ 319 | return UIWindow.getCurrentVC(form: rootVC) 320 | } 321 | return nil 322 | } 323 | 324 | static func currentVC() -> UIViewController?{ 325 | if let rootVC = self.current()?.rootViewController{ 326 | return self.getCurrentVC(form: rootVC) 327 | } 328 | return nil 329 | } 330 | 331 | static private func getCurrentVC(form rootVC:UIViewController) -> UIViewController?{ 332 | var currentVC:UIViewController? = nil 333 | var rootPre = rootVC 334 | if rootPre.presentedViewController != nil { 335 | rootPre = rootVC.presentedViewController! 336 | } 337 | if rootVC.isKind(of: UITabBarController.self) { 338 | if let selectedViewController = (rootVC as! UITabBarController).selectedViewController { 339 | currentVC = self.getCurrentVC(form: selectedViewController) 340 | } 341 | }else if rootVC.isKind(of: UINavigationController.self){ 342 | if let visibleViewController = (rootVC as! UINavigationController).visibleViewController { 343 | currentVC = self.getCurrentVC(form: visibleViewController) 344 | } 345 | }else{ 346 | currentVC = rootPre 347 | } 348 | return currentVC 349 | } 350 | } 351 | -------------------------------------------------------------------------------- /ZJJPopup.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | FF5791AC264CFC7900A9CD2A /* ZJJPopupView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF5791AA264CFC7900A9CD2A /* ZJJPopupView.swift */; }; 11 | FF5791AD264CFC7900A9CD2A /* ZJJPopupTopView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF5791AB264CFC7900A9CD2A /* ZJJPopupTopView.swift */; }; 12 | FFB4821526396D380062AB31 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFB4821426396D380062AB31 /* AppDelegate.swift */; }; 13 | FFB4821726396D380062AB31 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFB4821626396D380062AB31 /* SceneDelegate.swift */; }; 14 | FFB4821926396D380062AB31 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFB4821826396D380062AB31 /* ViewController.swift */; }; 15 | FFB4821C26396D380062AB31 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FFB4821A26396D380062AB31 /* Main.storyboard */; }; 16 | FFB4821E26396D390062AB31 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = FFB4821D26396D390062AB31 /* Assets.xcassets */; }; 17 | FFB4822126396D390062AB31 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FFB4821F26396D390062AB31 /* LaunchScreen.storyboard */; }; 18 | FFB4823226396D520062AB31 /* ZJJDefaultSelectTableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFB4822A26396D520062AB31 /* ZJJDefaultSelectTableView.swift */; }; 19 | FFB4823326396D520062AB31 /* ZJJOption.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFB4822B26396D520062AB31 /* ZJJOption.swift */; }; 20 | FFB4823426396D520062AB31 /* ZJJDefaultPickerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFB4822C26396D520062AB31 /* ZJJDefaultPickerView.swift */; }; 21 | FFB4823526396D520062AB31 /* ZJJOptionProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFB4822D26396D520062AB31 /* ZJJOptionProtocol.swift */; }; 22 | FFB4823826396D520062AB31 /* ZJJPopup.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFB4823026396D520062AB31 /* ZJJPopup.swift */; }; 23 | FFB4823926396D520062AB31 /* ZJJPopupModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFB4823126396D520062AB31 /* ZJJPopupModel.swift */; }; 24 | FFB4823D263970630062AB31 /* ZJJConfigModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFB4823C263970630062AB31 /* ZJJConfigModel.swift */; }; 25 | FFB48241263A52B90062AB31 /* ZJJDataModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFB48240263A52B90062AB31 /* ZJJDataModel.swift */; }; 26 | FFB48245263A7EF70062AB31 /* ZJJCustomCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFB48243263A7EF70062AB31 /* ZJJCustomCell.swift */; }; 27 | FFB48246263A7EF70062AB31 /* ZJJCustomCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = FFB48244263A7EF70062AB31 /* ZJJCustomCell.xib */; }; 28 | FFB4824E263A9E9A0062AB31 /* ZJJCustomView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFB4824D263A9E9A0062AB31 /* ZJJCustomView.swift */; }; 29 | FFB48251263A9EAC0062AB31 /* ZJJCustomView.xib in Resources */ = {isa = PBXBuildFile; fileRef = FFB48250263A9EAC0062AB31 /* ZJJCustomView.xib */; }; 30 | /* End PBXBuildFile section */ 31 | 32 | /* Begin PBXFileReference section */ 33 | FF5791AA264CFC7900A9CD2A /* ZJJPopupView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ZJJPopupView.swift; sourceTree = ""; }; 34 | FF5791AB264CFC7900A9CD2A /* ZJJPopupTopView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ZJJPopupTopView.swift; sourceTree = ""; }; 35 | FFB4821126396D380062AB31 /* ZJJPopup.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ZJJPopup.app; sourceTree = BUILT_PRODUCTS_DIR; }; 36 | FFB4821426396D380062AB31 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 37 | FFB4821626396D380062AB31 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; 38 | FFB4821826396D380062AB31 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 39 | FFB4821B26396D380062AB31 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 40 | FFB4821D26396D390062AB31 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 41 | FFB4822026396D390062AB31 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 42 | FFB4822226396D390062AB31 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 43 | FFB4822A26396D520062AB31 /* ZJJDefaultSelectTableView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ZJJDefaultSelectTableView.swift; sourceTree = ""; }; 44 | FFB4822B26396D520062AB31 /* ZJJOption.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ZJJOption.swift; sourceTree = ""; }; 45 | FFB4822C26396D520062AB31 /* ZJJDefaultPickerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ZJJDefaultPickerView.swift; sourceTree = ""; }; 46 | FFB4822D26396D520062AB31 /* ZJJOptionProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ZJJOptionProtocol.swift; sourceTree = ""; }; 47 | FFB4823026396D520062AB31 /* ZJJPopup.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ZJJPopup.swift; sourceTree = ""; }; 48 | FFB4823126396D520062AB31 /* ZJJPopupModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ZJJPopupModel.swift; sourceTree = ""; }; 49 | FFB4823C263970630062AB31 /* ZJJConfigModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ZJJConfigModel.swift; sourceTree = ""; }; 50 | FFB48240263A52B90062AB31 /* ZJJDataModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ZJJDataModel.swift; sourceTree = ""; }; 51 | FFB48243263A7EF70062AB31 /* ZJJCustomCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ZJJCustomCell.swift; sourceTree = ""; }; 52 | FFB48244263A7EF70062AB31 /* ZJJCustomCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ZJJCustomCell.xib; sourceTree = ""; }; 53 | FFB4824D263A9E9A0062AB31 /* ZJJCustomView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ZJJCustomView.swift; sourceTree = ""; }; 54 | FFB48250263A9EAC0062AB31 /* ZJJCustomView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ZJJCustomView.xib; sourceTree = ""; }; 55 | /* End PBXFileReference section */ 56 | 57 | /* Begin PBXFrameworksBuildPhase section */ 58 | FFB4820E26396D380062AB31 /* Frameworks */ = { 59 | isa = PBXFrameworksBuildPhase; 60 | buildActionMask = 2147483647; 61 | files = ( 62 | ); 63 | runOnlyForDeploymentPostprocessing = 0; 64 | }; 65 | /* End PBXFrameworksBuildPhase section */ 66 | 67 | /* Begin PBXGroup section */ 68 | FFB4820826396D380062AB31 = { 69 | isa = PBXGroup; 70 | children = ( 71 | FFB4821326396D380062AB31 /* ZJJPopup */, 72 | FFB4821226396D380062AB31 /* Products */, 73 | ); 74 | sourceTree = ""; 75 | }; 76 | FFB4821226396D380062AB31 /* Products */ = { 77 | isa = PBXGroup; 78 | children = ( 79 | FFB4821126396D380062AB31 /* ZJJPopup.app */, 80 | ); 81 | name = Products; 82 | sourceTree = ""; 83 | }; 84 | FFB4821326396D380062AB31 /* ZJJPopup */ = { 85 | isa = PBXGroup; 86 | children = ( 87 | FFB48253263ABB970062AB31 /* Example */, 88 | FFB4822926396D520062AB31 /* ZJJPopup */, 89 | FFB4821426396D380062AB31 /* AppDelegate.swift */, 90 | FFB4821626396D380062AB31 /* SceneDelegate.swift */, 91 | FFB4821A26396D380062AB31 /* Main.storyboard */, 92 | FFB4821D26396D390062AB31 /* Assets.xcassets */, 93 | FFB4821F26396D390062AB31 /* LaunchScreen.storyboard */, 94 | FFB4822226396D390062AB31 /* Info.plist */, 95 | ); 96 | path = ZJJPopup; 97 | sourceTree = ""; 98 | }; 99 | FFB4822926396D520062AB31 /* ZJJPopup */ = { 100 | isa = PBXGroup; 101 | children = ( 102 | FFB4822A26396D520062AB31 /* ZJJDefaultSelectTableView.swift */, 103 | FFB4822B26396D520062AB31 /* ZJJOption.swift */, 104 | FFB4822C26396D520062AB31 /* ZJJDefaultPickerView.swift */, 105 | FFB4822D26396D520062AB31 /* ZJJOptionProtocol.swift */, 106 | FF5791AB264CFC7900A9CD2A /* ZJJPopupTopView.swift */, 107 | FF5791AA264CFC7900A9CD2A /* ZJJPopupView.swift */, 108 | FFB4823026396D520062AB31 /* ZJJPopup.swift */, 109 | FFB4823126396D520062AB31 /* ZJJPopupModel.swift */, 110 | ); 111 | path = ZJJPopup; 112 | sourceTree = ""; 113 | }; 114 | FFB48253263ABB970062AB31 /* Example */ = { 115 | isa = PBXGroup; 116 | children = ( 117 | FFB4821826396D380062AB31 /* ViewController.swift */, 118 | FFB4823C263970630062AB31 /* ZJJConfigModel.swift */, 119 | FFB48240263A52B90062AB31 /* ZJJDataModel.swift */, 120 | FFB48243263A7EF70062AB31 /* ZJJCustomCell.swift */, 121 | FFB48244263A7EF70062AB31 /* ZJJCustomCell.xib */, 122 | FFB4824D263A9E9A0062AB31 /* ZJJCustomView.swift */, 123 | FFB48250263A9EAC0062AB31 /* ZJJCustomView.xib */, 124 | ); 125 | path = Example; 126 | sourceTree = ""; 127 | }; 128 | /* End PBXGroup section */ 129 | 130 | /* Begin PBXNativeTarget section */ 131 | FFB4821026396D380062AB31 /* ZJJPopup */ = { 132 | isa = PBXNativeTarget; 133 | buildConfigurationList = FFB4822526396D390062AB31 /* Build configuration list for PBXNativeTarget "ZJJPopup" */; 134 | buildPhases = ( 135 | FFB4820D26396D380062AB31 /* Sources */, 136 | FFB4820E26396D380062AB31 /* Frameworks */, 137 | FFB4820F26396D380062AB31 /* Resources */, 138 | ); 139 | buildRules = ( 140 | ); 141 | dependencies = ( 142 | ); 143 | name = ZJJPopup; 144 | productName = ZJJPopup; 145 | productReference = FFB4821126396D380062AB31 /* ZJJPopup.app */; 146 | productType = "com.apple.product-type.application"; 147 | }; 148 | /* End PBXNativeTarget section */ 149 | 150 | /* Begin PBXProject section */ 151 | FFB4820926396D380062AB31 /* Project object */ = { 152 | isa = PBXProject; 153 | attributes = { 154 | LastSwiftUpdateCheck = 1220; 155 | LastUpgradeCheck = 1220; 156 | TargetAttributes = { 157 | FFB4821026396D380062AB31 = { 158 | CreatedOnToolsVersion = 12.2; 159 | }; 160 | }; 161 | }; 162 | buildConfigurationList = FFB4820C26396D380062AB31 /* Build configuration list for PBXProject "ZJJPopup" */; 163 | compatibilityVersion = "Xcode 9.3"; 164 | developmentRegion = en; 165 | hasScannedForEncodings = 0; 166 | knownRegions = ( 167 | en, 168 | Base, 169 | ); 170 | mainGroup = FFB4820826396D380062AB31; 171 | productRefGroup = FFB4821226396D380062AB31 /* Products */; 172 | projectDirPath = ""; 173 | projectRoot = ""; 174 | targets = ( 175 | FFB4821026396D380062AB31 /* ZJJPopup */, 176 | ); 177 | }; 178 | /* End PBXProject section */ 179 | 180 | /* Begin PBXResourcesBuildPhase section */ 181 | FFB4820F26396D380062AB31 /* Resources */ = { 182 | isa = PBXResourcesBuildPhase; 183 | buildActionMask = 2147483647; 184 | files = ( 185 | FFB48251263A9EAC0062AB31 /* ZJJCustomView.xib in Resources */, 186 | FFB4822126396D390062AB31 /* LaunchScreen.storyboard in Resources */, 187 | FFB4821E26396D390062AB31 /* Assets.xcassets in Resources */, 188 | FFB4821C26396D380062AB31 /* Main.storyboard in Resources */, 189 | FFB48246263A7EF70062AB31 /* ZJJCustomCell.xib in Resources */, 190 | ); 191 | runOnlyForDeploymentPostprocessing = 0; 192 | }; 193 | /* End PBXResourcesBuildPhase section */ 194 | 195 | /* Begin PBXSourcesBuildPhase section */ 196 | FFB4820D26396D380062AB31 /* Sources */ = { 197 | isa = PBXSourcesBuildPhase; 198 | buildActionMask = 2147483647; 199 | files = ( 200 | FFB4824E263A9E9A0062AB31 /* ZJJCustomView.swift in Sources */, 201 | FFB4823826396D520062AB31 /* ZJJPopup.swift in Sources */, 202 | FFB4823926396D520062AB31 /* ZJJPopupModel.swift in Sources */, 203 | FFB48241263A52B90062AB31 /* ZJJDataModel.swift in Sources */, 204 | FFB4823D263970630062AB31 /* ZJJConfigModel.swift in Sources */, 205 | FFB4823226396D520062AB31 /* ZJJDefaultSelectTableView.swift in Sources */, 206 | FF5791AC264CFC7900A9CD2A /* ZJJPopupView.swift in Sources */, 207 | FFB4823426396D520062AB31 /* ZJJDefaultPickerView.swift in Sources */, 208 | FFB4821926396D380062AB31 /* ViewController.swift in Sources */, 209 | FFB4823526396D520062AB31 /* ZJJOptionProtocol.swift in Sources */, 210 | FFB4823326396D520062AB31 /* ZJJOption.swift in Sources */, 211 | FFB4821526396D380062AB31 /* AppDelegate.swift in Sources */, 212 | FF5791AD264CFC7900A9CD2A /* ZJJPopupTopView.swift in Sources */, 213 | FFB4821726396D380062AB31 /* SceneDelegate.swift in Sources */, 214 | FFB48245263A7EF70062AB31 /* ZJJCustomCell.swift in Sources */, 215 | ); 216 | runOnlyForDeploymentPostprocessing = 0; 217 | }; 218 | /* End PBXSourcesBuildPhase section */ 219 | 220 | /* Begin PBXVariantGroup section */ 221 | FFB4821A26396D380062AB31 /* Main.storyboard */ = { 222 | isa = PBXVariantGroup; 223 | children = ( 224 | FFB4821B26396D380062AB31 /* Base */, 225 | ); 226 | name = Main.storyboard; 227 | sourceTree = ""; 228 | }; 229 | FFB4821F26396D390062AB31 /* LaunchScreen.storyboard */ = { 230 | isa = PBXVariantGroup; 231 | children = ( 232 | FFB4822026396D390062AB31 /* Base */, 233 | ); 234 | name = LaunchScreen.storyboard; 235 | sourceTree = ""; 236 | }; 237 | /* End PBXVariantGroup section */ 238 | 239 | /* Begin XCBuildConfiguration section */ 240 | FFB4822326396D390062AB31 /* Debug */ = { 241 | isa = XCBuildConfiguration; 242 | buildSettings = { 243 | ALWAYS_SEARCH_USER_PATHS = NO; 244 | CLANG_ANALYZER_NONNULL = YES; 245 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 246 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 247 | CLANG_CXX_LIBRARY = "libc++"; 248 | CLANG_ENABLE_MODULES = YES; 249 | CLANG_ENABLE_OBJC_ARC = YES; 250 | CLANG_ENABLE_OBJC_WEAK = YES; 251 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 252 | CLANG_WARN_BOOL_CONVERSION = YES; 253 | CLANG_WARN_COMMA = YES; 254 | CLANG_WARN_CONSTANT_CONVERSION = YES; 255 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 256 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 257 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 258 | CLANG_WARN_EMPTY_BODY = YES; 259 | CLANG_WARN_ENUM_CONVERSION = YES; 260 | CLANG_WARN_INFINITE_RECURSION = YES; 261 | CLANG_WARN_INT_CONVERSION = YES; 262 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 263 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 264 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 265 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 266 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 267 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 268 | CLANG_WARN_STRICT_PROTOTYPES = YES; 269 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 270 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 271 | CLANG_WARN_UNREACHABLE_CODE = YES; 272 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 273 | COPY_PHASE_STRIP = NO; 274 | DEBUG_INFORMATION_FORMAT = dwarf; 275 | ENABLE_STRICT_OBJC_MSGSEND = YES; 276 | ENABLE_TESTABILITY = YES; 277 | GCC_C_LANGUAGE_STANDARD = gnu11; 278 | GCC_DYNAMIC_NO_PIC = NO; 279 | GCC_NO_COMMON_BLOCKS = YES; 280 | GCC_OPTIMIZATION_LEVEL = 0; 281 | GCC_PREPROCESSOR_DEFINITIONS = ( 282 | "DEBUG=1", 283 | "$(inherited)", 284 | ); 285 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 286 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 287 | GCC_WARN_UNDECLARED_SELECTOR = YES; 288 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 289 | GCC_WARN_UNUSED_FUNCTION = YES; 290 | GCC_WARN_UNUSED_VARIABLE = YES; 291 | IPHONEOS_DEPLOYMENT_TARGET = 14.2; 292 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 293 | MTL_FAST_MATH = YES; 294 | ONLY_ACTIVE_ARCH = YES; 295 | SDKROOT = iphoneos; 296 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 297 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 298 | }; 299 | name = Debug; 300 | }; 301 | FFB4822426396D390062AB31 /* Release */ = { 302 | isa = XCBuildConfiguration; 303 | buildSettings = { 304 | ALWAYS_SEARCH_USER_PATHS = NO; 305 | CLANG_ANALYZER_NONNULL = YES; 306 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 307 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 308 | CLANG_CXX_LIBRARY = "libc++"; 309 | CLANG_ENABLE_MODULES = YES; 310 | CLANG_ENABLE_OBJC_ARC = YES; 311 | CLANG_ENABLE_OBJC_WEAK = YES; 312 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 313 | CLANG_WARN_BOOL_CONVERSION = YES; 314 | CLANG_WARN_COMMA = YES; 315 | CLANG_WARN_CONSTANT_CONVERSION = YES; 316 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 317 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 318 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 319 | CLANG_WARN_EMPTY_BODY = YES; 320 | CLANG_WARN_ENUM_CONVERSION = YES; 321 | CLANG_WARN_INFINITE_RECURSION = YES; 322 | CLANG_WARN_INT_CONVERSION = YES; 323 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 324 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 325 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 326 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 327 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 328 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 329 | CLANG_WARN_STRICT_PROTOTYPES = YES; 330 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 331 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 332 | CLANG_WARN_UNREACHABLE_CODE = YES; 333 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 334 | COPY_PHASE_STRIP = NO; 335 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 336 | ENABLE_NS_ASSERTIONS = NO; 337 | ENABLE_STRICT_OBJC_MSGSEND = YES; 338 | GCC_C_LANGUAGE_STANDARD = gnu11; 339 | GCC_NO_COMMON_BLOCKS = YES; 340 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 341 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 342 | GCC_WARN_UNDECLARED_SELECTOR = YES; 343 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 344 | GCC_WARN_UNUSED_FUNCTION = YES; 345 | GCC_WARN_UNUSED_VARIABLE = YES; 346 | IPHONEOS_DEPLOYMENT_TARGET = 14.2; 347 | MTL_ENABLE_DEBUG_INFO = NO; 348 | MTL_FAST_MATH = YES; 349 | SDKROOT = iphoneos; 350 | SWIFT_COMPILATION_MODE = wholemodule; 351 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 352 | VALIDATE_PRODUCT = YES; 353 | }; 354 | name = Release; 355 | }; 356 | FFB4822626396D390062AB31 /* Debug */ = { 357 | isa = XCBuildConfiguration; 358 | buildSettings = { 359 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 360 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 361 | CODE_SIGN_STYLE = Automatic; 362 | DEVELOPMENT_TEAM = GG26W7FHYS; 363 | INFOPLIST_FILE = ZJJPopup/Info.plist; 364 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 365 | LD_RUNPATH_SEARCH_PATHS = ( 366 | "$(inherited)", 367 | "@executable_path/Frameworks", 368 | ); 369 | PRODUCT_BUNDLE_IDENTIFIER = com.bw.ZJJPopup; 370 | PRODUCT_NAME = "$(TARGET_NAME)"; 371 | SWIFT_VERSION = 5.0; 372 | TARGETED_DEVICE_FAMILY = "1,2"; 373 | }; 374 | name = Debug; 375 | }; 376 | FFB4822726396D390062AB31 /* Release */ = { 377 | isa = XCBuildConfiguration; 378 | buildSettings = { 379 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 380 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 381 | CODE_SIGN_STYLE = Automatic; 382 | DEVELOPMENT_TEAM = GG26W7FHYS; 383 | INFOPLIST_FILE = ZJJPopup/Info.plist; 384 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 385 | LD_RUNPATH_SEARCH_PATHS = ( 386 | "$(inherited)", 387 | "@executable_path/Frameworks", 388 | ); 389 | PRODUCT_BUNDLE_IDENTIFIER = com.bw.ZJJPopup; 390 | PRODUCT_NAME = "$(TARGET_NAME)"; 391 | SWIFT_VERSION = 5.0; 392 | TARGETED_DEVICE_FAMILY = "1,2"; 393 | }; 394 | name = Release; 395 | }; 396 | /* End XCBuildConfiguration section */ 397 | 398 | /* Begin XCConfigurationList section */ 399 | FFB4820C26396D380062AB31 /* Build configuration list for PBXProject "ZJJPopup" */ = { 400 | isa = XCConfigurationList; 401 | buildConfigurations = ( 402 | FFB4822326396D390062AB31 /* Debug */, 403 | FFB4822426396D390062AB31 /* Release */, 404 | ); 405 | defaultConfigurationIsVisible = 0; 406 | defaultConfigurationName = Release; 407 | }; 408 | FFB4822526396D390062AB31 /* Build configuration list for PBXNativeTarget "ZJJPopup" */ = { 409 | isa = XCConfigurationList; 410 | buildConfigurations = ( 411 | FFB4822626396D390062AB31 /* Debug */, 412 | FFB4822726396D390062AB31 /* Release */, 413 | ); 414 | defaultConfigurationIsVisible = 0; 415 | defaultConfigurationName = Release; 416 | }; 417 | /* End XCConfigurationList section */ 418 | }; 419 | rootObject = FFB4820926396D380062AB31 /* Project object */; 420 | } 421 | --------------------------------------------------------------------------------