Repository: hryk224/PCLBlurEffectAlert Branch: master Commit: c387b6962ff7 Files: 30 Total size: 126.6 KB Directory structure: gitextract_2sf9pjr1/ ├── .gitignore ├── .swift-version ├── Example/ │ ├── Example/ │ │ ├── AppDelegate.swift │ │ ├── Assets.swift │ │ ├── Assets.xcassets/ │ │ │ ├── AppIcon.appiconset/ │ │ │ │ └── Contents.json │ │ │ ├── Contents.json │ │ │ ├── sample1.imageset/ │ │ │ │ └── Contents.json │ │ │ ├── sample2.imageset/ │ │ │ │ └── Contents.json │ │ │ └── sampleBackground.imageset/ │ │ │ └── Contents.json │ │ ├── Base.lproj/ │ │ │ ├── LaunchScreen.storyboard │ │ │ └── MainViewController.storyboard │ │ ├── Info.plist │ │ └── MainViewController.swift │ └── Example.xcodeproj/ │ ├── project.pbxproj │ └── project.xcworkspace/ │ └── contents.xcworkspacedata ├── LICENSE ├── PCLBlurEffectAlert.podspec ├── PCLBlurEffectAlert.xcodeproj/ │ ├── PCLBlurEffectAlertTests_Info.plist │ ├── PCLBlurEffectAlert_Info.plist │ ├── project.pbxproj │ ├── project.xcworkspace/ │ │ └── contents.xcworkspacedata │ └── xcshareddata/ │ └── xcschemes/ │ ├── PCLBlurEffectAlert.xcscheme │ └── xcschememanagement.plist ├── Package.swift ├── README.md └── Sources/ ├── PCLBlurEffectAlert+Action.swift ├── PCLBlurEffectAlert+Controller.swift ├── PCLBlurEffectAlert+TransitionAnimator.swift ├── PCLBlurEffectAlert.h └── PCLBlurEffectAlert.swift ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ # Mac .DS_Store # Xcode build/* *.pbxuser !default.pbxuser *.mode1v3 !default.mode1v3 *.mode2v3 !default.mode2v3 *.perspectivev3 !default.perspectivev3 xcuserdata profile *.moved-aside DerivedData .idea/ *.ipa *.app *.xccheckout sort-Xcode-project-file ================================================ FILE: .swift-version ================================================ 3.0 ================================================ FILE: Example/Example/AppDelegate.swift ================================================ // // AppDelegate.swift // Example // // Created by yoshida hiroyuki on 2015/10/15. // Copyright © 2015年 yoshida hiroyuki. All rights reserved. // import UIKit @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. return true } func applicationWillResignActive(_ application: UIApplication) { // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. } func applicationDidEnterBackground(_ application: UIApplication) { // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. } func applicationWillEnterForeground(_ application: UIApplication) { // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. } func applicationDidBecomeActive(_ application: UIApplication) { // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. } func applicationWillTerminate(_ application: UIApplication) { // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. } } ================================================ FILE: Example/Example/Assets.swift ================================================ // // Assets.swift // Example // // Created by yoshida hiroyuki on 2017/02/27. // Copyright © 2017年 hiroyuki yoshida. All rights reserved. // import UIKit struct Assets { static let image = Assets.Image.share struct Image { static let share: Assets.Image = Image() var sample1: UIImage { return UIImage(named: "sample1")! } var sample2: UIImage { return UIImage(named: "sample2")! } } } ================================================ FILE: Example/Example/Assets.xcassets/AppIcon.appiconset/Contents.json ================================================ { "images" : [ { "idiom" : "iphone", "size" : "20x20", "scale" : "2x" }, { "idiom" : "iphone", "size" : "20x20", "scale" : "3x" }, { "idiom" : "iphone", "size" : "29x29", "scale" : "2x" }, { "idiom" : "iphone", "size" : "29x29", "scale" : "3x" }, { "idiom" : "iphone", "size" : "40x40", "scale" : "2x" }, { "idiom" : "iphone", "size" : "40x40", "scale" : "3x" }, { "idiom" : "iphone", "size" : "60x60", "scale" : "2x" }, { "idiom" : "iphone", "size" : "60x60", "scale" : "3x" }, { "idiom" : "ipad", "size" : "20x20", "scale" : "1x" }, { "idiom" : "ipad", "size" : "20x20", "scale" : "2x" }, { "idiom" : "ipad", "size" : "29x29", "scale" : "1x" }, { "idiom" : "ipad", "size" : "29x29", "scale" : "2x" }, { "idiom" : "ipad", "size" : "40x40", "scale" : "1x" }, { "idiom" : "ipad", "size" : "40x40", "scale" : "2x" }, { "idiom" : "ipad", "size" : "76x76", "scale" : "1x" }, { "idiom" : "ipad", "size" : "76x76", "scale" : "2x" }, { "idiom" : "ipad", "size" : "83.5x83.5", "scale" : "2x" } ], "info" : { "version" : 1, "author" : "xcode" } } ================================================ FILE: Example/Example/Assets.xcassets/Contents.json ================================================ { "info" : { "version" : 1, "author" : "xcode" } } ================================================ FILE: Example/Example/Assets.xcassets/sample1.imageset/Contents.json ================================================ { "images" : [ { "idiom" : "universal", "filename" : "recipes.png", "scale" : "1x" }, { "idiom" : "universal", "scale" : "2x" }, { "idiom" : "universal", "scale" : "3x" } ], "info" : { "version" : 1, "author" : "xcode" } } ================================================ FILE: Example/Example/Assets.xcassets/sample2.imageset/Contents.json ================================================ { "images" : [ { "idiom" : "universal", "filename" : "cat.jpg", "scale" : "1x" }, { "idiom" : "universal", "scale" : "2x" }, { "idiom" : "universal", "scale" : "3x" } ], "info" : { "version" : 1, "author" : "xcode" } } ================================================ FILE: Example/Example/Assets.xcassets/sampleBackground.imageset/Contents.json ================================================ { "images" : [ { "idiom" : "universal", "filename" : "PAKU160126410I9A5301-thumb-autox1600-21285.jpg", "scale" : "1x" }, { "idiom" : "universal", "scale" : "2x" }, { "idiom" : "universal", "scale" : "3x" } ], "info" : { "version" : 1, "author" : "xcode" } } ================================================ FILE: Example/Example/Base.lproj/LaunchScreen.storyboard ================================================ ================================================ FILE: Example/Example/Base.lproj/MainViewController.storyboard ================================================ ================================================ FILE: Example/Example/Info.plist ================================================ CFBundleDevelopmentRegion en CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName $(PRODUCT_NAME) CFBundlePackageType APPL CFBundleShortVersionString 1.0 CFBundleSignature ???? CFBundleVersion 1 LSRequiresIPhoneOS UILaunchStoryboardName LaunchScreen UIMainStoryboardFile MainViewController UIRequiredDeviceCapabilities armv7 UISupportedInterfaceOrientations UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight ================================================ FILE: Example/Example/MainViewController.swift ================================================ // // MainViewController.swift // PCLAlertController // // Created by yoshida hiroyuki on 2015/10/12. // Copyright © 2015年 yoshida hiroyuki. All rights reserved. // import UIKit import PCLBlurEffectAlert final class MainViewController: UIViewController { enum SampleRow: Int, CustomStringConvertible { case oneButton = 0 case okCancel case titleMessage case buttonOnly case colorful case textField case image static var count: Int { return 7 } var description: String { switch self { case .oneButton: return "One button" case .okCancel: return "OK / Cancel" case .titleMessage: return "Has title and message" case .buttonOnly: return "Button only" case .colorful: return "Colorful" case .textField: return "Has textFiled" case .image: return "Has image" } } } enum Segmented: Int { case a = 0, b, c var style: PCLBlurEffectAlert.ControllerStyle { switch self { case .a: return .alert case .b: return .alertVertical case .c: return .actionSheet } } var effect: UIBlurEffect { switch self { case .a: return UIBlurEffect(style: .extraLight) case .b: return UIBlurEffect(style: .light) case .c: return UIBlurEffect(style: .dark) } } } @IBOutlet weak var styleSegmentedControl: UISegmentedControl! @IBOutlet weak var blurEffecrSegmentedControl: UISegmentedControl! @IBOutlet var tableView: UITableView! { didSet { // tableView tableView.estimatedRowHeight = 100 tableView.layoutMargins = .zero tableView.separatorInset = .zero tableView.register(UITableViewCell.self, forCellReuseIdentifier: "Cell") } } fileprivate var textField1: UITextField? { didSet { textField1?.addTarget(self, action: #selector(MainViewController.textFieldEditingChanged(_:)), for: UIControlEvents.editingChanged) } } fileprivate var textField2: UITextField? { didSet { textField2?.addTarget(self, action: #selector(MainViewController.textFieldEditingChanged(_:)), for: UIControlEvents.editingChanged) } } override var prefersStatusBarHidden: Bool { return true } } // MARK: - UITableViewDelegate, UITableViewDataSource extension MainViewController: UITableViewDelegate, UITableViewDataSource { func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return SampleRow.count } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "Cell")! cell.selectionStyle = .none cell.backgroundColor = .clear cell.contentView.backgroundColor = .clear let row = SampleRow(rawValue: indexPath.row) cell.textLabel?.text = row?.description return cell } func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { guard let style = Segmented(rawValue: styleSegmentedControl.selectedSegmentIndex)?.style, let effectStyle = Segmented(rawValue: blurEffecrSegmentedControl.selectedSegmentIndex), let row = SampleRow(rawValue: indexPath.row) else { return } let effect = effectStyle.effect switch row { case .oneButton: let alertController = PCLBlurEffectAlertController(title: row.description, message: nil, effect: effect, style: style) let action = PCLBlurEffectAlertAction(title: "OK!", style: .default) { _ in print("You pressed OK!") } alertController.addAction(action) alertController.show() case .okCancel: let alertController = PCLBlurEffectAlertController(title: row.description, message: nil, effect: effect, style: style) let action1 = PCLBlurEffectAlertAction(title: "OK!", style: .default) { _ in print("You pressed OK!") } let cancelAction = PCLBlurEffectAlertAction(title: "Cancel", style: .cancel) { _ in print("You pressed Cancel") } alertController.configure(alertViewWidth: 200) alertController.configure(cornerRadius: 0) alertController.addAction(action1) alertController.addAction(cancelAction) alertController.show() case .titleMessage: let alertController = PCLBlurEffectAlertController(title: "How are you doing?", message: "Press a button!", effect: effect, style: style) switch effectStyle { case .c: alertController.configure(titleColor: .white) alertController.configure(messageColor: .white) default: break } let action1 = PCLBlurEffectAlertAction(title: "I’m fine.", style: .default) { _ in print("You pressed I’m fine.") } let action2 = PCLBlurEffectAlertAction(title: "Not so good.", style: .default) { _ in print("You pressed Not so good.") } alertController.addAction(action1) alertController.addAction(action2) alertController.show() case .buttonOnly: let alertController = PCLBlurEffectAlertController(title: nil, message: nil, effect: effect, style: style) let action1 = PCLBlurEffectAlertAction(title: "Default", style: .default) { _ in print("You pressed Default") } let action2 = PCLBlurEffectAlertAction(title: "Destructive", style: .destructive) { _ in print("You pressed Destructive") } let cancelAction = PCLBlurEffectAlertAction(title: "Cancel", style: .cancel) { _ in print("You pressed Cancel") } alertController.addAction(action1) alertController.addAction(action2) alertController.addAction(cancelAction) alertController.show() case .colorful: let alertController = PCLBlurEffectAlertController(title: "title title title\ntitle title title title", message: "message message message\n message message", effect: effect, style: style) alertController.configure(overlayBackgroundColor: UIColor.orange) alertController.configure(titleFont: UIFont.systemFont(ofSize: 24), titleColor: .red) alertController.configure(messageColor: .blue) alertController.configure(buttonFont: [.default: UIFont.systemFont(ofSize: 24), .destructive: UIFont.boldSystemFont(ofSize: 20), .cancel: UIFont.systemFont(ofSize: 14)], buttonTextColor: [.default: .brown, .destructive: .blue, .cancel: .gray]) let action1 = PCLBlurEffectAlertAction(title: "Default", style: .default) { _ in print("You pressed No.1") } let action2 = PCLBlurEffectAlertAction(title: "Destructive", style: .destructive) { _ in print("You pressed No.2") } let cancelAction = PCLBlurEffectAlertAction(title: "Cancel", style: .cancel) { _ in print("You pressed Cancel") } alertController.addAction(action1) alertController.addAction(action2) alertController.addAction(cancelAction) alertController.show() case .textField: let alertController = PCLBlurEffectAlertController(title: "title title title title title title title", message: "message message message message message", effect: effect, style: style) alertController.addTextField { textField in self.textField1 = textField } alertController.addTextField { textField in self.textField2 = textField } alertController.configure(textFieldsViewBackgroundColor: UIColor.white.withAlphaComponent(0.1)) alertController.configure(textFieldBorderColor: .black) alertController.configure(buttonDisableTextColor: [.default: .lightGray, .destructive: .lightGray]) let action1 = PCLBlurEffectAlertAction(title: "Default", style: .default) { _ in print("You pressed Default") } let action2 = PCLBlurEffectAlertAction(title: "Destructive", style: .destructive) { _ in print("You pressed Destructive") } let cancelAction = PCLBlurEffectAlertAction(title: "Cancel", style: .cancel) { _ in print("You pressed Cancel") } action1.isEnabled = false action2.isEnabled = false alertController.addAction(action1) alertController.addAction(action2) alertController.addAction(cancelAction) alertController.show() case .image: let alertController = PCLBlurEffectAlertController(title: "title title title title title title title", message: "message message message message message", effect: effect, style: style) alertController.addImageView(with: Assets.image.sample2) switch effectStyle { case .c: alertController.configure(titleColor: .white) alertController.configure(messageColor: .white) default: break } let catAction = PCLBlurEffectAlertAction(title: "Cat?", style: .default) { _ in print("You pressed Cat?") } let dogAction = PCLBlurEffectAlertAction(title: "Dog?", style: .default) { _ in print("You pressed Dog?") } alertController.addAction(catAction) alertController.addAction(dogAction) alertController.show() } } } // MARK: - UITextFieldDelegate extension MainViewController { func textFieldEditingChanged(_ textField: UITextField) { guard let alertController = presentedViewController as? PCLBlurEffectAlertController else { return } alertController.actions.filter { $0.style != .cancel }.forEach { $0.isEnabled = textField1?.text?.isEmpty == false && textField2?.text?.isEmpty == false } } } ================================================ FILE: Example/Example.xcodeproj/project.pbxproj ================================================ // !$*UTF8*$! { archiveVersion = 1; classes = { }; objectVersion = 46; objects = { /* Begin PBXBuildFile section */ 935BD7381CE272F400E5FDF7 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 935BD7371CE272F400E5FDF7 /* AppDelegate.swift */; }; 935BD73A1CE272F400E5FDF7 /* MainViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 935BD7391CE272F400E5FDF7 /* MainViewController.swift */; }; 935BD73D1CE272F400E5FDF7 /* MainViewController.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 935BD73B1CE272F400E5FDF7 /* MainViewController.storyboard */; }; 935BD73F1CE272F400E5FDF7 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 935BD73E1CE272F400E5FDF7 /* Assets.xcassets */; }; 935BD7421CE272F400E5FDF7 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 935BD7401CE272F400E5FDF7 /* LaunchScreen.storyboard */; }; ED413F421D8AA81B0024036E /* PCLBlurEffectAlert.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ED413F411D8AA8130024036E /* PCLBlurEffectAlert.framework */; }; ED413F431D8AA81B0024036E /* PCLBlurEffectAlert.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = ED413F411D8AA8130024036E /* PCLBlurEffectAlert.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; ED6872461E63C12900B8A0B4 /* Assets.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED6872451E63C12900B8A0B4 /* Assets.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ ED413F401D8AA8130024036E /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = ED413F3C1D8AA8130024036E /* PCLBlurEffectAlert.xcodeproj */; proxyType = 2; remoteGlobalIDString = 935BD7B81CE274A500E5FDF7; remoteInfo = PCLBlurEffectAlert; }; ED413F441D8AA81B0024036E /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = ED413F3C1D8AA8130024036E /* PCLBlurEffectAlert.xcodeproj */; proxyType = 1; remoteGlobalIDString = OBJ_17; remoteInfo = PCLBlurEffectAlert; }; /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ 935BD7EA1CE2759F00E5FDF7 /* Embed Frameworks */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; dstPath = ""; dstSubfolderSpec = 10; files = ( ED413F431D8AA81B0024036E /* PCLBlurEffectAlert.framework in Embed Frameworks */, ); name = "Embed Frameworks"; runOnlyForDeploymentPostprocessing = 0; }; /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ 935BD7341CE272F400E5FDF7 /* Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Example.app; sourceTree = BUILT_PRODUCTS_DIR; }; 935BD7371CE272F400E5FDF7 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 935BD7391CE272F400E5FDF7 /* MainViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainViewController.swift; sourceTree = ""; }; 935BD73C1CE272F400E5FDF7 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/MainViewController.storyboard; sourceTree = ""; }; 935BD73E1CE272F400E5FDF7 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 935BD7411CE272F400E5FDF7 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 935BD7431CE272F400E5FDF7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; ED413F3C1D8AA8130024036E /* PCLBlurEffectAlert.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = PCLBlurEffectAlert.xcodeproj; path = ../PCLBlurEffectAlert.xcodeproj; sourceTree = ""; }; ED6872451E63C12900B8A0B4 /* Assets.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Assets.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ 935BD7311CE272F400E5FDF7 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( ED413F421D8AA81B0024036E /* PCLBlurEffectAlert.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ 935BD72B1CE272F400E5FDF7 = { isa = PBXGroup; children = ( 935BD7361CE272F400E5FDF7 /* Example */, ED413F3B1D8AA8130024036E /* Frameworks */, 935BD7351CE272F400E5FDF7 /* Products */, ); sourceTree = ""; }; 935BD7351CE272F400E5FDF7 /* Products */ = { isa = PBXGroup; children = ( 935BD7341CE272F400E5FDF7 /* Example.app */, ); name = Products; sourceTree = ""; }; 935BD7361CE272F400E5FDF7 /* Example */ = { isa = PBXGroup; children = ( 935BD7371CE272F400E5FDF7 /* AppDelegate.swift */, ED6872451E63C12900B8A0B4 /* Assets.swift */, 935BD73E1CE272F400E5FDF7 /* Assets.xcassets */, 935BD7431CE272F400E5FDF7 /* Info.plist */, 935BD7401CE272F400E5FDF7 /* LaunchScreen.storyboard */, 935BD73B1CE272F400E5FDF7 /* MainViewController.storyboard */, 935BD7391CE272F400E5FDF7 /* MainViewController.swift */, ); path = Example; sourceTree = ""; }; ED413F3B1D8AA8130024036E /* Frameworks */ = { isa = PBXGroup; children = ( ED413F3C1D8AA8130024036E /* PCLBlurEffectAlert.xcodeproj */, ); name = Frameworks; sourceTree = ""; }; ED413F3D1D8AA8130024036E /* Products */ = { isa = PBXGroup; children = ( ED413F411D8AA8130024036E /* PCLBlurEffectAlert.framework */, ); name = Products; sourceTree = ""; }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ 935BD7331CE272F400E5FDF7 /* Example */ = { isa = PBXNativeTarget; buildConfigurationList = 935BD7461CE272F400E5FDF7 /* Build configuration list for PBXNativeTarget "Example" */; buildPhases = ( 935BD7301CE272F400E5FDF7 /* Sources */, 935BD7311CE272F400E5FDF7 /* Frameworks */, 935BD7321CE272F400E5FDF7 /* Resources */, 935BD7EA1CE2759F00E5FDF7 /* Embed Frameworks */, ); buildRules = ( ); dependencies = ( ED413F451D8AA81B0024036E /* PBXTargetDependency */, ); name = Example; productName = Example; productReference = 935BD7341CE272F400E5FDF7 /* Example.app */; productType = "com.apple.product-type.application"; }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ 935BD72C1CE272F400E5FDF7 /* Project object */ = { isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0730; LastUpgradeCheck = 0800; ORGANIZATIONNAME = "hiroyuki yoshida"; TargetAttributes = { 935BD7331CE272F400E5FDF7 = { CreatedOnToolsVersion = 7.3.1; LastSwiftMigration = 0800; }; }; }; buildConfigurationList = 935BD72F1CE272F400E5FDF7 /* Build configuration list for PBXProject "Example" */; compatibilityVersion = "Xcode 3.2"; developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( en, Base, ); mainGroup = 935BD72B1CE272F400E5FDF7; productRefGroup = 935BD7351CE272F400E5FDF7 /* Products */; projectDirPath = ""; projectReferences = ( { ProductGroup = ED413F3D1D8AA8130024036E /* Products */; ProjectRef = ED413F3C1D8AA8130024036E /* PCLBlurEffectAlert.xcodeproj */; }, ); projectRoot = ""; targets = ( 935BD7331CE272F400E5FDF7 /* Example */, ); }; /* End PBXProject section */ /* Begin PBXReferenceProxy section */ ED413F411D8AA8130024036E /* PCLBlurEffectAlert.framework */ = { isa = PBXReferenceProxy; fileType = wrapper.framework; path = PCLBlurEffectAlert.framework; remoteRef = ED413F401D8AA8130024036E /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXReferenceProxy section */ /* Begin PBXResourcesBuildPhase section */ 935BD7321CE272F400E5FDF7 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( 935BD73F1CE272F400E5FDF7 /* Assets.xcassets in Resources */, 935BD7421CE272F400E5FDF7 /* LaunchScreen.storyboard in Resources */, 935BD73D1CE272F400E5FDF7 /* MainViewController.storyboard in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ 935BD7301CE272F400E5FDF7 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 935BD7381CE272F400E5FDF7 /* AppDelegate.swift in Sources */, ED6872461E63C12900B8A0B4 /* Assets.swift in Sources */, 935BD73A1CE272F400E5FDF7 /* MainViewController.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ ED413F451D8AA81B0024036E /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = PCLBlurEffectAlert; targetProxy = ED413F441D8AA81B0024036E /* PBXContainerItemProxy */; }; /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ 935BD73B1CE272F400E5FDF7 /* MainViewController.storyboard */ = { isa = PBXVariantGroup; children = ( 935BD73C1CE272F400E5FDF7 /* Base */, ); name = MainViewController.storyboard; sourceTree = ""; }; 935BD7401CE272F400E5FDF7 /* LaunchScreen.storyboard */ = { isa = PBXVariantGroup; children = ( 935BD7411CE272F400E5FDF7 /* Base */, ); name = LaunchScreen.storyboard; sourceTree = ""; }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ 935BD7441CE272F400E5FDF7 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", ); GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 8.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; }; name = Debug; }; 935BD7451CE272F400E5FDF7 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_NO_COMMON_BLOCKS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 8.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; VALIDATE_PRODUCT = YES; }; name = Release; }; 935BD7471CE272F400E5FDF7 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = Example/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = io.github.hryk224.Example; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 3.0; }; name = Debug; }; 935BD7481CE272F400E5FDF7 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = Example/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = io.github.hryk224.Example; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 3.0; }; name = Release; }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ 935BD72F1CE272F400E5FDF7 /* Build configuration list for PBXProject "Example" */ = { isa = XCConfigurationList; buildConfigurations = ( 935BD7441CE272F400E5FDF7 /* Debug */, 935BD7451CE272F400E5FDF7 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; 935BD7461CE272F400E5FDF7 /* Build configuration list for PBXNativeTarget "Example" */ = { isa = XCConfigurationList; buildConfigurations = ( 935BD7471CE272F400E5FDF7 /* Debug */, 935BD7481CE272F400E5FDF7 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; rootObject = 935BD72C1CE272F400E5FDF7 /* Project object */; } ================================================ FILE: Example/Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata ================================================ ================================================ FILE: LICENSE ================================================ The MIT License (MIT) Copyright (c) 2015 hryk224 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: PCLBlurEffectAlert.podspec ================================================ Pod::Spec.new do |s| s.name = "PCLBlurEffectAlert" s.version = "2.1.1" s.summary = "Custom Swift AlertController." s.homepage = "https://github.com/hryk224/PCLBlurEffectAlert" s.screenshots = "https://raw.githubusercontent.com/wiki/hryk224/PCLBlurEffectAlert/images/sample1.gif" s.license = { :type => "MIT", :file => "LICENSE" } s.author = { "hyyk224" => "hryk224@gmail.com" } s.platform = :ios, "8.0" s.source = { :git => "https://github.com/hryk224/PCLBlurEffectAlert.git", :tag => "#{s.version}" } s.source_files = "Sources/*.{h,swift}" s.frameworks = "UIKit" s.requires_arc = true end ================================================ FILE: PCLBlurEffectAlert.xcodeproj/PCLBlurEffectAlertTests_Info.plist ================================================ CFBundleDevelopmentRegion en CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName $(PRODUCT_NAME) CFBundlePackageType BNDL CFBundleShortVersionString 1.0 CFBundleSignature ???? CFBundleVersion $(CURRENT_PROJECT_VERSION) NSPrincipalClass ================================================ FILE: PCLBlurEffectAlert.xcodeproj/PCLBlurEffectAlert_Info.plist ================================================ CFBundleDevelopmentRegion en CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName $(PRODUCT_NAME) CFBundlePackageType FMWK CFBundleShortVersionString 2.1.1 CFBundleSignature ???? CFBundleVersion $(CURRENT_PROJECT_VERSION) NSPrincipalClass ================================================ FILE: PCLBlurEffectAlert.xcodeproj/project.pbxproj ================================================ // !$*UTF8*$! { archiveVersion = 1; classes = { }; objectVersion = 46; objects = { /* Begin PBXBuildFile section */ 93905ED61E630FC500A483CD /* PCLBlurEffectAlert+TransitionAnimator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93905ED51E630FC500A483CD /* PCLBlurEffectAlert+TransitionAnimator.swift */; }; 93CE21B21E563926003D4137 /* PCLBlurEffectAlert+Action.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93CE21B01E563926003D4137 /* PCLBlurEffectAlert+Action.swift */; }; 93CE21B31E563926003D4137 /* PCLBlurEffectAlert+Controller.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93CE21B11E563926003D4137 /* PCLBlurEffectAlert+Controller.swift */; }; 93CE21B51E563938003D4137 /* PCLBlurEffectAlert.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93CE21B41E563938003D4137 /* PCLBlurEffectAlert.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ 93905ED51E630FC500A483CD /* PCLBlurEffectAlert+TransitionAnimator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "PCLBlurEffectAlert+TransitionAnimator.swift"; sourceTree = ""; }; 93CE21AF1E563926003D4137 /* PCLBlurEffectAlert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PCLBlurEffectAlert.h; sourceTree = ""; }; 93CE21B01E563926003D4137 /* PCLBlurEffectAlert+Action.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "PCLBlurEffectAlert+Action.swift"; sourceTree = ""; }; 93CE21B11E563926003D4137 /* PCLBlurEffectAlert+Controller.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "PCLBlurEffectAlert+Controller.swift"; sourceTree = ""; }; 93CE21B41E563938003D4137 /* PCLBlurEffectAlert.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PCLBlurEffectAlert.swift; sourceTree = ""; }; OBJ_15 /* PCLBlurEffectAlert.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = PCLBlurEffectAlert.framework; sourceTree = BUILT_PRODUCTS_DIR; }; OBJ_6 /* Package.swift */ = {isa = PBXFileReference; explicitFileType = sourcecode.swift; path = Package.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ OBJ_23 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 0; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ OBJ_14 /* Products */ = { isa = PBXGroup; children = ( OBJ_15 /* PCLBlurEffectAlert.framework */, ); name = Products; sourceTree = BUILT_PRODUCTS_DIR; }; OBJ_5 = { isa = PBXGroup; children = ( OBJ_6 /* Package.swift */, OBJ_7 /* Sources */, OBJ_14 /* Products */, ); sourceTree = ""; }; OBJ_7 /* Sources */ = { isa = PBXGroup; children = ( OBJ_8 /* PCLBlurEffectAlert */, ); path = Sources; sourceTree = ""; }; OBJ_8 /* PCLBlurEffectAlert */ = { isa = PBXGroup; children = ( 93CE21B01E563926003D4137 /* PCLBlurEffectAlert+Action.swift */, 93CE21B11E563926003D4137 /* PCLBlurEffectAlert+Controller.swift */, 93905ED51E630FC500A483CD /* PCLBlurEffectAlert+TransitionAnimator.swift */, 93CE21AF1E563926003D4137 /* PCLBlurEffectAlert.h */, 93CE21B41E563938003D4137 /* PCLBlurEffectAlert.swift */, ); name = PCLBlurEffectAlert; path = Sources; sourceTree = SOURCE_ROOT; }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ OBJ_17 /* PCLBlurEffectAlert */ = { isa = PBXNativeTarget; buildConfigurationList = OBJ_18 /* Build configuration list for PBXNativeTarget "PCLBlurEffectAlert" */; buildPhases = ( OBJ_21 /* Sources */, OBJ_23 /* Frameworks */, ); buildRules = ( ); dependencies = ( ); name = PCLBlurEffectAlert; productName = PCLBlurEffectAlert; productReference = OBJ_15 /* PCLBlurEffectAlert.framework */; productType = "com.apple.product-type.framework"; }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ OBJ_1 /* Project object */ = { isa = PBXProject; attributes = { LastUpgradeCheck = 9999; TargetAttributes = { OBJ_17 = { LastSwiftMigration = 0820; }; }; }; buildConfigurationList = OBJ_2 /* Build configuration list for PBXProject "PCLBlurEffectAlert" */; compatibilityVersion = "Xcode 3.2"; developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( en, ); mainGroup = OBJ_5; productRefGroup = OBJ_14 /* Products */; projectDirPath = ""; projectRoot = ""; targets = ( OBJ_17 /* PCLBlurEffectAlert */, ); }; /* End PBXProject section */ /* Begin PBXSourcesBuildPhase section */ OBJ_21 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 0; files = ( 93CE21B21E563926003D4137 /* PCLBlurEffectAlert+Action.swift in Sources */, 93CE21B31E563926003D4137 /* PCLBlurEffectAlert+Controller.swift in Sources */, 93905ED61E630FC500A483CD /* PCLBlurEffectAlert+TransitionAnimator.swift in Sources */, 93CE21B51E563938003D4137 /* PCLBlurEffectAlert.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin XCBuildConfiguration section */ OBJ_19 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_MODULES = YES; DEFINES_MODULE = YES; ENABLE_TESTABILITY = YES; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PLATFORM_DIR)/Developer/Library/Frameworks", ); HEADER_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = PCLBlurEffectAlert.xcodeproj/PCLBlurEffectAlert_Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(TOOLCHAIN_DIR)/usr/lib/swift/macosx"; OTHER_LDFLAGS = "$(inherited)"; OTHER_SWIFT_FLAGS = "$(inherited)"; PRODUCT_BUNDLE_IDENTIFIER = PCLBlurEffectAlert; PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)"; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 3.0; TARGET_NAME = PCLBlurEffectAlert; }; name = Debug; }; OBJ_20 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_MODULES = YES; DEFINES_MODULE = YES; ENABLE_TESTABILITY = YES; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PLATFORM_DIR)/Developer/Library/Frameworks", ); HEADER_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = PCLBlurEffectAlert.xcodeproj/PCLBlurEffectAlert_Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(TOOLCHAIN_DIR)/usr/lib/swift/macosx"; OTHER_LDFLAGS = "$(inherited)"; OTHER_SWIFT_FLAGS = "$(inherited)"; PRODUCT_BUNDLE_IDENTIFIER = PCLBlurEffectAlert; PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)"; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SWIFT_VERSION = 3.0; TARGET_NAME = PCLBlurEffectAlert; }; name = Release; }; OBJ_3 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = dwarf; DYLIB_INSTALL_NAME_BASE = "@rpath"; ENABLE_NS_ASSERTIONS = YES; GCC_OPTIMIZATION_LEVEL = 0; IPHONEOS_DEPLOYMENT_TARGET = 8.0; MACOSX_DEPLOYMENT_TARGET = 10.10; ONLY_ACTIVE_ARCH = YES; OTHER_SWIFT_FLAGS = "-DXcode"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = "iphonesimulator iphoneos"; SWIFT_ACTIVE_COMPILATION_CONDITIONS = SWIFT_PACKAGE; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 3.0; USE_HEADERMAP = NO; }; name = Debug; }; OBJ_4 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_INSTALL_NAME_BASE = "@rpath"; GCC_OPTIMIZATION_LEVEL = s; IPHONEOS_DEPLOYMENT_TARGET = 8.0; MACOSX_DEPLOYMENT_TARGET = 10.10; OTHER_SWIFT_FLAGS = "-DXcode"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = "iphonesimulator iphoneos"; SWIFT_ACTIVE_COMPILATION_CONDITIONS = SWIFT_PACKAGE; SWIFT_OPTIMIZATION_LEVEL = "-O"; SWIFT_VERSION = 3.0; USE_HEADERMAP = NO; }; name = Release; }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ OBJ_18 /* Build configuration list for PBXNativeTarget "PCLBlurEffectAlert" */ = { isa = XCConfigurationList; buildConfigurations = ( OBJ_19 /* Debug */, OBJ_20 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Debug; }; OBJ_2 /* Build configuration list for PBXProject "PCLBlurEffectAlert" */ = { isa = XCConfigurationList; buildConfigurations = ( OBJ_3 /* Debug */, OBJ_4 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Debug; }; /* End XCConfigurationList section */ }; rootObject = OBJ_1 /* Project object */; } ================================================ FILE: PCLBlurEffectAlert.xcodeproj/project.xcworkspace/contents.xcworkspacedata ================================================ ================================================ FILE: PCLBlurEffectAlert.xcodeproj/xcshareddata/xcschemes/PCLBlurEffectAlert.xcscheme ================================================ ================================================ FILE: PCLBlurEffectAlert.xcodeproj/xcshareddata/xcschemes/xcschememanagement.plist ================================================ SchemeUserState PCLBlurEffectAlert.xcscheme SuppressBuildableAutocreation ================================================ FILE: Package.swift ================================================ import PackageDescription let package = Package( name: "PCLBlurEffectAlert", targets: [], dependencies: [ .Package(url: "https://github.com/hryk224/PCLBlurEffectAlert", majorVersion: 2), ] ) ================================================ FILE: README.md ================================================ # PCLBlurEffectAlert Swift AlertController, use UIVisualeffectview [![Cocoapods Compatible](http://img.shields.io/cocoapods/v/PCLBlurEffectAlert.svg?style=flat)](http://cocoadocs.org/docsets/PCLBlurEffectAlert) [![Swift 3.0](https://img.shields.io/badge/Swift-3.0-orange.svg?style=flat)](https://developer.apple.com/swift/) ## Requirements - iOS 8.0+ - Swift 3.0+ - ARC ## Feature - [x] Change color - [x] Change effect - [x] Change font - [x] Use UITextField - [x] Use UIImageView ## install #### Cocoapods Adding the following to your `Podfile` and running `pod install`: ```Ruby use_frameworks! pod "PCLBlurEffectAlert" ``` ### import ```Swift import PCLBlurEffectAlert ``` ## Initialize #### UIBlurEffect ```Swift // Default effect: UIBlurEffect(style: .extraLight) convenience init(title: String?, message: String?, effect: UIBlurEffect, style: PCLBlurEffectAlert.ControllerStyle) ``` `style` => `alert`, `alertVertical`, `actionSheet` When `actions` count becomes more than 3, `alert` and `alertVertical` is the same as. ## Usage #### Example ```Swift let alertController = PCLBlurEffectAlertController(title: "How are you doing?", message: "Press a button!", effect: UIBlurEffect(style: .lightdark) style: .alert)' // Customize if needed alertController.configure(titleColor: .white) alertController.configure(buttonFont: [.default: UIFont.systemFont(ofSize: 24), .destructive: UIFont.boldSystemFont(ofSize: 20), .cancel: UIFont.systemFont(ofSize: 14)]) // Adds ImageView alertController.addImageView(with: ) // Adds TextField alertController.addTextField() // Adds actions let action = PCLBlurEffectAlertAction(title: "I’m fine.", style: .default) { _ in } let cancelAction = PCLBlurEffectAlertAction(title: "Not so good.", style: .cancel) { _ in } alertController.addAction(action) alertController.addAction(cancelAction) // Presented alertController.show() // or present(alertController, animated: true, completion: nil) ``` #### Sources ```Swift // Adds Actions open func addAction(_ action: PCLBlurEffectAlertAction) // Adds ImageView open func addImageView(with image: UIImage, configurationHandler: ((UIImageView?) -> Void)? = nil) // Adds TextFields open func addTextField(with configurationHandler: ((UITextField?) -> Void)? = nil) // Presented open func show() ``` ## Customize ```Swift // Default ActionSheet: UIScreen.main.bounds.width - (margin * 2) // Default Alert: 320 - (margin * 2) func configure(alertViewWidth: CGFloat) // Default: 4 func configure(cornerRadius: CGFloat) // Default: 1 / UIScreen.main.scale func configure(thin: CGFloat) // Default: 8 func configure(margin: CGFloat) /// Color // Default: UIColor.black.withAlphaComponent(0.3) func configure(overlayBackgroundColor: UIColor) // Default: .clear func configure(backgroundColor: UIColor) /// Text // Default: .boldSystemFont(ofSize: 16) // Default: .black func configure(titleFont: UIFont, titleColor: UIColor) // Default: .systemFont(ofSize: 14) // Default: .black func configure(messageFont: UIFont, messageColor: UIColor) // Default: // .default: UIFont.systemFont(ofSize: 16), // .cancel: UIFont.systemFont(ofSize: 16), // .destructive: UIFont.systemFont(ofSize: 16) func configure(buttonFont: [PCLBlurEffectAlert.ActionStyle : UIFont]) // Default: // .default: .black, // .cancel: .black, // .destructive: .red func configure(buttonTextColor: [PCLBlurEffectAlert.ActionStyle : UIColor]) // Default: // .default: .gray, // .cancel: .gray, // .destructive: .gray func configure(buttonDisableTextColor: [PCLBlurEffectAlert.ActionStyle : UIColor]) /// Button // Default: 44 func configure(buttonHeight: CGFloat) // Default: .clear func configure(buttonBackgroundColor: UIColor) // Default: 32 func configure(textFieldHeight: CGFloat) // Default: UIColor.white.withAlphaComponent(0.1) func configure(textFieldsViewBackgroundColor: UIColor) // Default: UIColor.black.withAlphaComponent(0.15) func configure(textFieldBorderColor: UIColor) ``` ## More Examples ```Swift let alertController = PCLBlurEffectAlertController(title: "How are you doing?", message: "Press a button!", style: .alert) let action1 = PCLBlurEffectAlertAction(title: "I’m fine.", style: .default) { _ in } let action2 = PCLBlurEffectAlertAction(title: "Not so good.", style: .default) { _ in } alertController.addAction(action1) alertController.addAction(action2) alertController.show() ``` ```Swift let alertController = PCLBlurEffectAlertController(title: "title title title title title title title", message: "message message message message message", effect: UIBlurEffect(style: .light), style: .alert) alertController.addTextField { _ in } alertController.addTextField { _ in } alertController.configure(textFieldsViewBackgroundColor: UIColor.white.withAlphaComponent(0.1)) alertController.configure(textFieldBorderColor: .black) alertController.configure(buttonDisableTextColor: [.default: .lightGray, .destructive: .lightGray]) let action1 = PCLBlurEffectAlertAction(title: "Default", style: .default) { _ in } let action2 = PCLBlurEffectAlertAction(title: "Destructive", style: .destructive) { _ in } let cancelAction = PCLBlurEffectAlertAction(title: "Cancel", style: .cancel) { _ in } alertController.addAction(action1) alertController.addAction(action2) alertController.addAction(cancelAction) alertController.show() ``` ```Swift let alertController = PCLBlurEffectAlertController(title: "How are you doing?", message: "Press a button!", effect: UIBlurEffect(style: .dark), style: .actionSheet) let action1 = PCLBlurEffectAlertAction(title: "I’m fine.", style: .default) { _ in } let action2 = PCLBlurEffectAlertAction(title: "Not so good.", style: .default) { _ in } alertController.addAction(action1) alertController.addAction(action2) alertController.show() ``` ```Swift let alertController = PCLBlurEffectAlertController(title: "title title title title title title title", message: "message message message message message", style: .actionSheet) alertController.addTextField() alertController.addTextField() alertController.configure(textFieldsViewBackgroundColor: UIColor.white.withAlphaComponent(0.1)) alertController.configure(textFieldBorderColor: .black) alertController.configure(buttonDisableTextColor: [.default: .lightGray, .destructive: .lightGray]) let action1 = PCLBlurEffectAlertAction(title: "Default", style: .default) { _ in } let action2 = PCLBlurEffectAlertAction(title: "Destructive", style: .destructive) { _ in } let cancelAction = PCLBlurEffectAlertAction(title: "Cancel", style: .cancel) { _ in } alertController.addAction(action1) alertController.addAction(action2) alertController.addAction(cancelAction) alertController.show() ``` ```Swift let alertController = PCLBlurEffectAlertController(title: "title title title title title title title", message: "message message message message message", style: .alert) alertController.addImageView(with: UIImage(named: "cat")!) let catAction = PCLBlurEffectAlertAction(title: "Cat?", style: .default) { _ in print("You pressed Cat?") } let dogAction = PCLBlurEffectAlertAction(title: "Dog?", style: .default) { _ in print("You pressed Dog?") } alertController.addAction(catAction) alertController.addAction(dogAction) alertController.show() ``` ## Photos from * by [pakutaso.com](https://www.pakutaso.com/) * by [FLATICON](http://www.flaticon.com/) ## Acknowledgements * Inspired by [DOAlertController](https://github.com/okmr-d/DOAlertController) in [okmr-d](https://github.com/okmr-d). ## License This project is made available under the MIT license. See LICENSE file for details. ================================================ FILE: Sources/PCLBlurEffectAlert+Action.swift ================================================ // // PCLBlurEffectAlert+Action.swift // PCLBlurEffectAlert // // Created by yoshida hiroyuki on 2016/09/15. // Copyright © 2016年 hiroyuki yoshida. All rights reserved. // import UIKit public typealias PCLBlurEffectAlertAction = PCLBlurEffectAlert.Action extension PCLBlurEffectAlert { open class Action { var tag: Int = -1 var title: String? open var style: PCLBlurEffectAlert.ActionStyle var handler: ((PCLBlurEffectAlert.Action?) -> Void)? var button: UIButton! var visualEffectView: UIVisualEffectView? lazy var backgroundView: UIView = { return UIView() }() open var isEnabled: Bool = true { didSet { guard oldValue != isEnabled else { return } PCLBlurEffectAlert.NotificationManager.shared.postAlertActionEnabledDidChangeNotification() } } public init(title: String, style: PCLBlurEffectAlert.ActionStyle, handler: ((PCLBlurEffectAlert.Action?) -> Void)?) { self.title = title self.style = style self.handler = handler let button = UIButton(type: .custom) button.tag = tag button.adjustsImageWhenHighlighted = false button.adjustsImageWhenDisabled = false button.layer.masksToBounds = true button.setTitle(title, for: .normal) button.titleLabel?.numberOfLines = 1 button.titleLabel?.lineBreakMode = .byTruncatingTail button.titleLabel?.textAlignment = .center self.button = button } } } ================================================ FILE: Sources/PCLBlurEffectAlert+Controller.swift ================================================ // // PCLBlurEffectAlert+Controller.swift // PCLBlurEffectAlert // // Created by yoshida hiroyuki on 2016/09/15. // Copyright © 2016年 hiroyuki yoshida. All rights reserved. // import UIKit public typealias PCLBlurEffectAlertController = PCLBlurEffectAlert.Controller extension PCLBlurEffectAlert { open class Controller: UIViewController { // Property fileprivate var isNeedlayout = true fileprivate var message: String? fileprivate var textField: UITextField? fileprivate var imageView: UIImageView? var style: PCLBlurEffectAlert.ControllerStyle = .actionSheet fileprivate var effect: UIBlurEffect = UIBlurEffect(style: .extraLight) // Actions open fileprivate(set) var actions: [PCLBlurEffectAlertAction] = [] fileprivate var cancelAction: PCLBlurEffectAlertAction? fileprivate var cancelActionTag: Int? fileprivate var keyboardHeight: CGFloat = 0 // TextFields fileprivate var textFields: [UITextField] = [] // Getter fileprivate var isActionSheet: Bool { return style == .actionSheet } fileprivate var isAlert: Bool { return style == .alert } fileprivate var isAlertVertical: Bool { return style == .alertVertical } fileprivate var hasTitle: Bool { return title?.isEmpty == false } fileprivate var hasMessage: Bool { return message?.isEmpty == false } fileprivate var hasImageView: Bool { return imageView != nil } fileprivate var hasTextField: Bool { return !textFields.isEmpty } // OverlayView let overlayView = UIView() fileprivate let tapGestureRecognizer = UITapGestureRecognizer() // ContainerView let containerView = RespondsView() fileprivate var containerViewBottomLayoutConstraint: NSLayoutConstraint! // AlertView let alertView = UIView() fileprivate var alertViewWidthConstraint: NSLayoutConstraint! fileprivate var alertViewHeightConstraint: NSLayoutConstraint! // CornerView let cornerView = UIView() fileprivate var cornerViewHeightConstraint: NSLayoutConstraint! // textAreaView fileprivate let textAreaView = UIView() fileprivate var textAreaHeight: CGFloat = 0 fileprivate var textAreaViewHeightConstraint: NSLayoutConstraint! fileprivate var textAreaVisualEffectView: UIVisualEffectView! fileprivate var textAreaVisualEffectViewHeightConstraint: NSLayoutConstraint! fileprivate let textAreaBackgroundView = UIView() fileprivate var textAreaBackgroundViewHeightConstraint: NSLayoutConstraint! // titleLabel fileprivate let titleLabel = UILabel() // messageLabel fileprivate let messageLabel = UILabel() // Customize fileprivate var alertViewWidth: CGFloat = 0 fileprivate var cornerRadius: CGFloat = 0 fileprivate var thin: CGFloat = 1 / UIScreen.main.scale fileprivate var margin: CGFloat = 8 fileprivate var overlayBackgroundColor: UIColor = UIColor.black.withAlphaComponent(0.3) fileprivate var backgroundColor: UIColor = .clear fileprivate var buttonBackgroundColor: UIColor = .clear fileprivate var textFieldsViewBackgroundColor: UIColor = UIColor.white.withAlphaComponent(0.1) fileprivate var titleFont: UIFont = .boldSystemFont(ofSize: 16) fileprivate var titleColor: UIColor = .black fileprivate var messageFont: UIFont = .systemFont(ofSize: 14) fileprivate var messageColor: UIColor = .black fileprivate var buttonFont: [PCLBlurEffectAlert.ActionStyle : UIFont] = [ .default: UIFont.systemFont(ofSize: 16), .cancel: UIFont.systemFont(ofSize: 16), .destructive: UIFont.systemFont(ofSize: 16) ] fileprivate var buttonTextColor: [PCLBlurEffectAlert.ActionStyle : UIColor] = [ .default: .black, .cancel: .black, .destructive: .red ] fileprivate var buttonDisableTextColor: [PCLBlurEffectAlert.ActionStyle : UIColor] = [ .default: .gray, .cancel: .gray, .destructive: .gray ] fileprivate var textFieldHeight: CGFloat = 32 fileprivate var textFieldBorderColor = UIColor.black.withAlphaComponent(0.15) fileprivate var buttonHeight: CGFloat = 44 private var tintColor: UIColor { return view.tintColor } open override var prefersStatusBarHidden: Bool { return presentingViewController?.prefersStatusBarHidden ?? super.prefersStatusBarHidden } public convenience init(title: String?, message: String?, effect: UIBlurEffect = UIBlurEffect(style: .extraLight), style: PCLBlurEffectAlert.ControllerStyle) { self.init(nibName: nil, bundle: nil) self.title = title self.message = message self.style = style self.effect = effect self.textAreaVisualEffectView = UIVisualEffectView(effect: effect) as UIVisualEffectView // NotificationCenter PCLBlurEffectAlert.NotificationManager.shared.addAlertActionEnabledDidChangeNotificationObserver(self) PCLBlurEffectAlert.NotificationManager.shared.addKeyboardNotificationObserver(self) modalPresentationStyle = .overCurrentContext transitioningDelegate = self view.frame.size = UIScreen.main.bounds.size overlayView.frame = UIScreen.main.bounds view.insertSubview(overlayView, at: 0) view.addSubview(containerView) containerView.delegate = self containerView.addSubview(alertView) cornerView.addSubview(textAreaBackgroundView) cornerView.addSubview(textAreaVisualEffectView) cornerView.addSubview(textAreaView) alertView.addSubview(cornerView) switch style { case .actionSheet: alertViewWidth = UIScreen.main.bounds.width - (margin * 2) default: alertViewWidth = 320 - (margin * 2) } cornerRadius = 4 buttonTextColor[.default] = tintColor buttonTextColor[.cancel] = tintColor configureConstraints() } deinit { PCLBlurEffectAlert.NotificationManager.shared.removeAlertActionEnabledDidChangeNotificationObserver(self) PCLBlurEffectAlert.NotificationManager.shared.removeKeyboardNotificationObserver(self) } // layout open override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) adjustLayout() } } } // MARK: - User Setting extension PCLBlurEffectAlertController { // ActionSheet: var alertViewWidth: CGFloat = UIScreen.main.bounds.width - (margin * 2) // Alert: var alertViewWidth = 320 - (margin * 2) open func configure(alertViewWidth: CGFloat) { self.alertViewWidth = alertViewWidth } // var cornerRadius: CGFloat = 0 open func configure(cornerRadius: CGFloat) { self.cornerRadius = cornerRadius } // var thin: CGFloat = 1 / UIScreen.main.scale open func configure(thin: CGFloat) { self.thin = thin } // var margin: CGFloat = 8 open func configure(margin: CGFloat) { self.margin = margin } // var backgroundColor = .clear open func configure(backgroundColor: UIColor) { self.backgroundColor = backgroundColor } // var buttonBackgroundColor = .clear open func configure(buttonBackgroundColor: UIColor) { self.buttonBackgroundColor = buttonBackgroundColor } // var overlayBackgroundColor = UIColor.black.withAlphaComponent(0.3) open func configure(overlayBackgroundColor: UIColor) { self.overlayBackgroundColor = overlayBackgroundColor } // var textFieldsViewBackgroundColor = UIColor.white.withAlphaComponent(0.1) open func configure(textFieldsViewBackgroundColor: UIColor) { self.textFieldsViewBackgroundColor = textFieldsViewBackgroundColor } // var titleFont = UIFont.boldSystemFont(ofSize: 16) // var titleColor: UIColor = .brown open func configure(titleFont: UIFont) { self.titleFont = titleFont } open func configure(titleColor: UIColor) { self.titleColor = titleColor } open func configure(titleFont: UIFont, titleColor: UIColor) { self.titleFont = titleFont self.titleColor = titleColor } // var messageFont = UIFont.systemFont(ofSize: 14) // var messageColor: UIColor = .black open func configure(messageFont: UIFont) { self.messageFont = messageFont } open func configure(messageColor: UIColor) { self.messageColor = messageColor } open func configure(messageFont: UIFont, messageColor: UIColor) { self.messageFont = messageFont self.messageColor = messageColor } // var buttonFont: [PCLBlurEffectAlert.ActionStyle : UIFont] = [ // .default: UIFont.systemFont(ofSize: 16), // .cancel: UIFont.systemFont(ofSize: 16), // .destructive: UIFont.systemFont(ofSize: 16) // ] // var buttonTextColor: [PCLBlurEffectAlert.ActionStyle : UIColor] = [ // .default: .black, // .cancel: .gray, // .destructive: .red // ] // var buttonDisableTextColor: [PCLBlurEffectAlert.ActionStyle : UIColor] = [ // .default: .black, // .cancel: .black, // .destructive: .red // ] open func configure(buttonFont font: [PCLBlurEffectAlert.ActionStyle : UIFont]? = nil, buttonTextColor textColor: [PCLBlurEffectAlert.ActionStyle : UIColor]? = nil, buttonDisableTextColor disableTextColor: [PCLBlurEffectAlert.ActionStyle : UIColor]? = nil) { if let font = font?[.default] { self.buttonFont[.default] = font } if let font = font?[.destructive] { self.buttonFont[.destructive] = font } if let font = font?[.cancel] { self.buttonFont[.cancel] = font } if let textColor = textColor?[.default] { self.buttonTextColor[.default] = textColor } if let textColor = textColor?[.destructive] { self.buttonTextColor[.destructive] = textColor } if let textColor = textColor?[.cancel] { self.buttonTextColor[.cancel] = textColor } if let textColor = disableTextColor?[.default] { self.buttonDisableTextColor[.default] = textColor } if let textColor = disableTextColor?[.destructive] { self.buttonDisableTextColor[.destructive] = textColor } if let textColor = disableTextColor?[.cancel] { self.buttonDisableTextColor[.cancel] = textColor } } // var textFieldHeight: CGFloat = 32 open func configure(textFieldHeight: CGFloat) { self.textFieldHeight = textFieldHeight } // var textFieldBorderColor = UIColor.black.withAlphaComponent(0.15) open func configure(textFieldBorderColor: UIColor) { self.textFieldBorderColor = textFieldBorderColor } // var buttonHeight: CGFloat = 44 open func configure(buttonHeight: CGFloat) { self.buttonHeight = buttonHeight } // Adds Action open func addAction(_ action: PCLBlurEffectAlertAction) { // Error if action.style.isCancel && actions.filter({ $0.style.isCancel }).count > 0 { fatalError("Can not be used plurality cancel button") } action.tag = actions.count action.button?.tag = action.tag if action.style.isCancel { cancelAction = action cancelActionTag = action.tag } actions.append(action) action.button?.setTitle(action.title, for: .normal) action.button?.isEnabled = action.isEnabled action.visualEffectView = UIVisualEffectView(effect: effect) as UIVisualEffectView action.visualEffectView?.isUserInteractionEnabled = false } // Adds TextFields open func addTextField(with configurationHandler: ((UITextField?) -> Void)? = nil) { let textField = UITextField() textField.backgroundColor = .clear configurationHandler?(textField) textFields.append(textField) } // Adds ImageView open func addImageView(with image: UIImage, configurationHandler: ((UIImageView?) -> Void)? = nil) { let imageView = UIImageView() imageView.contentMode = .scaleAspectFill imageView.clipsToBounds = true imageView.backgroundColor = .clear imageView.image = image configurationHandler?(imageView) self.imageView = imageView } // show open func show() { DispatchQueue.main.async { UIApplication.shared.topViewController?.present(self, animated: true, completion: nil) } } } // MARK: - Private private extension PCLBlurEffectAlertController { func configureConstraints() { configureContainerViewConstraints() configureAlertViewConstraints() configureCornerViewConstraints() configureTextAreaViewConstraints() } func configureContainerViewConstraints() { containerView.translatesAutoresizingMaskIntoConstraints = false let topConstraint = NSLayoutConstraint(item: containerView, attribute: .top, relatedBy: .equal, toItem: view, attribute: .top, multiplier: 1, constant: 0) let rightConstraint = NSLayoutConstraint(item: containerView, attribute: .right, relatedBy: .equal, toItem: view, attribute: .right, multiplier: 1, constant: 0) let leftConstraint = NSLayoutConstraint(item: containerView, attribute: .left, relatedBy: .equal, toItem: view, attribute: .left, multiplier: 1, constant: 0) containerViewBottomLayoutConstraint = NSLayoutConstraint(item: containerView, attribute: .bottom, relatedBy: .equal, toItem: view, attribute: .bottom, multiplier: 1, constant: 0) view.addConstraints([topConstraint, rightConstraint, leftConstraint, containerViewBottomLayoutConstraint]) } func configureAlertViewConstraints() { alertView.translatesAutoresizingMaskIntoConstraints = false switch style { case .actionSheet: let centerXConstraint = NSLayoutConstraint(item: alertView, attribute: .centerX, relatedBy: .equal, toItem: containerView, attribute: .centerX, multiplier: 1, constant: 0) let bottomConstraint = NSLayoutConstraint(item: alertView, attribute: .bottom, relatedBy: .equal, toItem: containerView, attribute: .bottom, multiplier: 1, constant: -(margin)) alertViewWidthConstraint = NSLayoutConstraint(item: alertView, attribute: .width, relatedBy: .equal, toItem: nil, attribute: .width, multiplier: 1, constant: alertViewWidth) alertViewHeightConstraint = NSLayoutConstraint(item: alertView, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .height, multiplier: 1, constant: 0) containerView.addConstraints([centerXConstraint, bottomConstraint, alertViewWidthConstraint, alertViewHeightConstraint]) default: let centerXConstraint = NSLayoutConstraint(item: alertView, attribute: .centerX, relatedBy: .equal, toItem: containerView, attribute: .centerX, multiplier: 1, constant: 0) let centerYConstraint = NSLayoutConstraint(item: alertView, attribute: .centerY, relatedBy: .equal, toItem: containerView, attribute: .centerY, multiplier: 1, constant: 0) alertViewWidthConstraint = NSLayoutConstraint(item: alertView, attribute: .width, relatedBy: .equal, toItem: nil, attribute: .width, multiplier: 1, constant: alertViewWidth) alertViewHeightConstraint = NSLayoutConstraint(item: alertView, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .height, multiplier: 1, constant: 0) containerView.addConstraints([centerXConstraint, centerYConstraint, alertViewWidthConstraint, alertViewHeightConstraint]) } } func configureCornerViewConstraints() { cornerView.translatesAutoresizingMaskIntoConstraints = false switch style { case .actionSheet: let topConstraint = NSLayoutConstraint(item: cornerView, attribute: .top, relatedBy: .equal, toItem: alertView, attribute: .top, multiplier: 1, constant: 0) let rightConstraint = NSLayoutConstraint(item: cornerView, attribute: .right, relatedBy: .equal, toItem: alertView, attribute: .right, multiplier: 1, constant: 0) let leftConstraint = NSLayoutConstraint(item: cornerView, attribute: .left, relatedBy: .equal, toItem: alertView, attribute: .left, multiplier: 1, constant: 0) cornerViewHeightConstraint = NSLayoutConstraint(item: cornerView, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .height, multiplier: 1, constant: 0) alertView.addConstraints([topConstraint, rightConstraint, leftConstraint, cornerViewHeightConstraint]) default: let topConstraint = NSLayoutConstraint(item: cornerView, attribute: .top, relatedBy: .equal, toItem: alertView, attribute: .top, multiplier: 1, constant: 0) let rightConstraint = NSLayoutConstraint(item: cornerView, attribute: .right, relatedBy: .equal, toItem: alertView, attribute: .right, multiplier: 1, constant: 0) let leftConstraint = NSLayoutConstraint(item: cornerView, attribute: .left, relatedBy: .equal, toItem: alertView, attribute: .left, multiplier: 1, constant: 0) let bottomLayoutConstraint = NSLayoutConstraint(item: cornerView, attribute: .bottom, relatedBy: .equal, toItem: alertView, attribute: .bottom, multiplier: 1, constant: 0) alertView.addConstraints([topConstraint, rightConstraint, leftConstraint, bottomLayoutConstraint]) } } func configureTextAreaViewConstraints() { textAreaView.translatesAutoresizingMaskIntoConstraints = false textAreaVisualEffectView.translatesAutoresizingMaskIntoConstraints = false textAreaBackgroundView.translatesAutoresizingMaskIntoConstraints = false let textAreaViewTopConstraint = NSLayoutConstraint(item: textAreaView, attribute: .top, relatedBy: .equal, toItem: cornerView, attribute: .top, multiplier: 1, constant: 0) let textAreaViewRightConstraint = NSLayoutConstraint(item: textAreaView, attribute: .right, relatedBy: .equal, toItem: cornerView, attribute: .right, multiplier: 1, constant: 0) let textAreaViewLeftConstraint = NSLayoutConstraint(item: textAreaView, attribute: .left, relatedBy: .equal, toItem: cornerView, attribute: .left, multiplier: 1, constant: 0) textAreaViewHeightConstraint = NSLayoutConstraint(item: textAreaView, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .height, multiplier: 1, constant: 0) cornerView.addConstraints([textAreaViewTopConstraint, textAreaViewRightConstraint, textAreaViewLeftConstraint, textAreaViewHeightConstraint]) let textAreaVisualEffectViewTopConstraint = NSLayoutConstraint(item: textAreaVisualEffectView, attribute: .top, relatedBy: .equal, toItem: cornerView, attribute: .top, multiplier: 1, constant: 0) let textAreaVisualEffectViewRightConstraint = NSLayoutConstraint(item: textAreaVisualEffectView, attribute: .right, relatedBy: .equal, toItem: cornerView, attribute: .right, multiplier: 1, constant: 0) let textAreaVisualEffectViewLeftConstraint = NSLayoutConstraint(item: textAreaVisualEffectView, attribute: .left, relatedBy: .equal, toItem: cornerView, attribute: .left, multiplier: 1, constant: 0) textAreaVisualEffectViewHeightConstraint = NSLayoutConstraint(item: textAreaVisualEffectView, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .height, multiplier: 1, constant: 0) cornerView.addConstraints([textAreaVisualEffectViewTopConstraint, textAreaVisualEffectViewRightConstraint, textAreaVisualEffectViewLeftConstraint, textAreaVisualEffectViewHeightConstraint]) let textAreaBackgroundViewTopConstraint = NSLayoutConstraint(item: textAreaBackgroundView, attribute: .top, relatedBy: .equal, toItem: cornerView, attribute: .top, multiplier: 1, constant: 0) let textAreaBackgroundViewRightConstraint = NSLayoutConstraint(item: textAreaBackgroundView, attribute: .right, relatedBy: .equal, toItem: cornerView, attribute: .right, multiplier: 1, constant: 0) let textAreaBackgroundViewLeftConstraint = NSLayoutConstraint(item: textAreaBackgroundView, attribute: .left, relatedBy: .equal, toItem: cornerView, attribute: .left, multiplier: 1, constant: 0) textAreaBackgroundViewHeightConstraint = NSLayoutConstraint(item: textAreaBackgroundView, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .height, multiplier: 1, constant: 0) cornerView.addConstraints([textAreaBackgroundViewTopConstraint, textAreaBackgroundViewRightConstraint, textAreaBackgroundViewLeftConstraint, textAreaBackgroundViewHeightConstraint]) } func adjustLayout() { guard isNeedlayout else { return } isNeedlayout = false overlayView.backgroundColor = overlayBackgroundColor alertView.layer.cornerRadius = cornerRadius alertView.clipsToBounds = true alertViewWidthConstraint.constant = alertViewWidth cornerView.layer.cornerRadius = cornerRadius cornerView.clipsToBounds = true var textAreaPositionY: CGFloat = 0 textAreaPositionY += (margin * 2) let textAreaWidth = alertViewWidth - (margin * 4) if hasTitle { titleLabel.frame.size = CGSize(width: textAreaWidth, height: 0) titleLabel.numberOfLines = 0 titleLabel.textAlignment = .center titleLabel.font = titleFont titleLabel.textColor = titleColor titleLabel.text = title titleLabel.sizeToFit() titleLabel.frame = CGRect(x: margin * 2, y: textAreaPositionY, width: textAreaWidth, height: titleLabel.frame.height) textAreaView.addSubview(titleLabel) textAreaPositionY += titleLabel.frame.height } if hasMessage { if hasTitle { textAreaPositionY += margin } messageLabel.frame.size = CGSize(width: textAreaWidth, height: 0) messageLabel.numberOfLines = 0 messageLabel.textAlignment = .center messageLabel.text = message messageLabel.font = messageFont messageLabel.textColor = messageColor messageLabel.sizeToFit() messageLabel.frame = CGRect(x: margin * 2, y: textAreaPositionY, width: textAreaWidth, height: messageLabel.frame.height) textAreaView.addSubview(messageLabel) textAreaPositionY += messageLabel.frame.height } if let imageView = imageView, let image = imageView.image { // hasImageView if hasTitle || hasMessage { textAreaPositionY += margin } let width = min(alertViewWidth - (margin * 2), image.size.width) let height = (width / image.size.width) * image.size.height let size = CGSize(width: width, height: height) imageView.frame = CGRect(x: (alertViewWidth - size.width) / 2, y: textAreaPositionY, width: size.width, height: size.height) textAreaView.addSubview(imageView) textAreaPositionY += imageView.frame.height } if hasTextField { if hasTitle || hasMessage || hasImageView { textAreaPositionY += margin } let textFieldsView = UIView() textFieldsView.backgroundColor = textFieldsViewBackgroundColor textFieldsView.layer.cornerRadius = (cornerRadius / 2) textFieldsView.clipsToBounds = true let textFieldsViewWidth = textAreaWidth var textFieldsViewHeight: CGFloat = 0 textFieldsView.frame = CGRect(x: margin * 2, y: textAreaPositionY + margin, width: textFieldsViewWidth, height: textFieldsViewHeight) textFields.enumerated().forEach { index, textField in textField.frame = CGRect(x: margin, y: CGFloat(index) * textFieldHeight, width: textFieldsViewWidth - (2 * margin), height: textFieldHeight) textFieldsView.addSubview(textField) textFieldsViewHeight += textFieldHeight if index > 0 { let topBorder = CALayer() topBorder.frame = CGRect(x: -margin, y: 0, width: textFieldsViewWidth + (margin * 2), height: thin) topBorder.backgroundColor = textFieldBorderColor.cgColor textField.layer.sublayers = [topBorder] textField.clipsToBounds = false } } textFieldsView.layer.borderColor = textFieldBorderColor.cgColor textFieldsView.layer.borderWidth = thin textAreaView.addSubview(textFieldsView) textFieldsView.frame.size.height = textFieldsViewHeight textAreaPositionY += textFieldsView.frame.size.height } if hasTitle || hasMessage || hasImageView || hasTextField { textAreaPositionY += (margin * 2) textAreaBackgroundView.backgroundColor = backgroundColor } else { textAreaPositionY = 0 } textAreaHeight = textAreaPositionY textAreaViewHeightConstraint.constant = textAreaHeight textAreaVisualEffectViewHeightConstraint.constant = textAreaHeight textAreaBackgroundViewHeightConstraint.constant = textAreaHeight var cornerViewHeight = textAreaHeight var alertViewHeight: CGFloat = 0 // button setUp switch style { case .alert where actions.count == 2 && (hasTitle || hasMessage || hasImageView || hasTextField): cornerViewHeight += thin actions.enumerated().forEach { index, action in let rect = CGRect(x: CGFloat(index) * alertViewWidth / 2, y: cornerViewHeight, width: alertViewWidth / 2, height: buttonHeight) action.backgroundView.frame = rect action.backgroundView.backgroundColor = buttonBackgroundColor action.visualEffectView?.frame = rect action.button.frame = rect if let visualEffectView = action.visualEffectView { cornerView.addSubview(action.backgroundView) cornerView.addSubview(visualEffectView) } action.button.setTitleColor(buttonTextColor[action.style], for: .normal) action.button.setTitleColor(buttonDisableTextColor[action.style], for: .disabled) action.button.titleLabel?.font = buttonFont[action.style] if index == actions.count - 1 { action.visualEffectView?.frame.origin.x += thin action.visualEffectView?.frame.size.width -= thin action.button.frame.origin.x += thin action.button.frame.size.width -= thin } action.button.addTarget(self, action: #selector(PCLBlurEffectAlertController.buttonWasTouchUpInside(_:)), for: .touchUpInside) cornerView.addSubview(action.button) } cornerViewHeight += buttonHeight case .alert, .alertVertical: actions.enumerated().forEach { index, action in cornerViewHeight += thin let rect = CGRect(x: 0, y: cornerViewHeight, width: alertViewWidth, height: buttonHeight) action.backgroundView.frame = rect action.backgroundView.backgroundColor = buttonBackgroundColor action.visualEffectView?.frame = rect action.button.frame = rect if let visualEffectView = action.visualEffectView { cornerView.addSubview(action.backgroundView) cornerView.addSubview(visualEffectView) } action.button.setTitleColor(buttonTextColor[action.style], for: .normal) action.button.setTitleColor(buttonDisableTextColor[action.style], for: .disabled) action.button.titleLabel?.font = buttonFont[action.style] action.button.addTarget(self, action: #selector(PCLBlurEffectAlertController.buttonWasTouchUpInside(_:)), for: .touchUpInside) cornerView.addSubview(action.button) cornerViewHeight += buttonHeight } default: var cancelIndex = -1 actions.enumerated().forEach { index, action in switch action.style { case .cancel: cancelIndex = index default: cornerViewHeight += thin let rect = CGRect(x: 0, y: cornerViewHeight, width: alertViewWidth, height: buttonHeight) action.backgroundView.frame = rect action.backgroundView.backgroundColor = buttonBackgroundColor action.visualEffectView?.frame = rect action.button.frame = rect if let visualEffectView = action.visualEffectView { cornerView.addSubview(action.backgroundView) cornerView.addSubview(visualEffectView) } action.button.setTitleColor(buttonTextColor[action.style], for: .normal) action.button.setTitleColor(buttonDisableTextColor[action.style], for: .disabled) action.button.titleLabel?.font = buttonFont[action.style] action.button.addTarget(self, action: #selector(PCLBlurEffectAlertController.buttonWasTouchUpInside(_:)), for: .touchUpInside) cornerView.addSubview(action.button) cornerViewHeight += buttonHeight } } alertViewHeight = cornerViewHeight if cancelIndex >= 0 { // cancel alertViewHeight += margin let action = actions[cancelIndex] let rect = CGRect(x: 0, y: alertViewHeight, width: alertViewWidth, height: buttonHeight) action.backgroundView.frame = rect action.backgroundView.backgroundColor = buttonBackgroundColor action.visualEffectView?.frame = rect action.button.frame = rect if let visualEffectView = action.visualEffectView { alertView.addSubview(action.backgroundView) alertView.addSubview(visualEffectView) } action.button.setTitleColor(buttonTextColor[action.style], for: .normal) action.button.setTitleColor(buttonDisableTextColor[action.style], for: .disabled) action.button.titleLabel?.font = buttonFont[action.style] action.button.addTarget(self, action: #selector(PCLBlurEffectAlertController.buttonWasTouchUpInside(_:)), for: .touchUpInside) action.backgroundView.clipsToBounds = true action.backgroundView.layer.cornerRadius = cornerRadius action.visualEffectView?.clipsToBounds = true action.visualEffectView?.layer.cornerRadius = cornerRadius action.button.clipsToBounds = true action.button.layer.cornerRadius = cornerRadius alertView.addSubview(action.button) alertViewHeight += buttonHeight } } switch style { case .actionSheet: cornerViewHeightConstraint.constant = cornerViewHeight default: alertViewHeight = cornerViewHeight } alertViewHeightConstraint.constant = alertViewHeight view.layoutIfNeeded() } dynamic func buttonWasTouchUpInside(_ sender: UIButton) { sender.isSelected = true let action = actions[sender.tag] dismiss(animated: true) { action.handler?(action) } } } // MARK: - PCLRespondsViewDelegate extension PCLBlurEffectAlertController: PCLRespondsViewDelegate { func respondsViewDidTouch(_ view: UIView) { guard isActionSheet else { return } guard let cancelAction = cancelAction else { return } dismiss(animated: true) { cancelAction.handler?(cancelAction) } } } // MARK: - PCLAlertKeyboardNotificationObserver, PCLAlertActionEnabledDidChangeNotificationObserver extension PCLBlurEffectAlertController : PCLAlertKeyboardNotificationObserver, PCLAlertActionEnabledDidChangeNotificationObserver { func keyboardWillHide(_ notification: Notification) { keyboardHeight = 0 containerViewBottomLayoutConstraint.constant = keyboardHeight UIView.animate(withDuration: 0.3) { self.view.layoutIfNeeded() } } func keyboardWillShow(_ notification: Notification) { guard let userInfo = notification.userInfo as? [String: AnyObject], let keyboardSize = userInfo[UIKeyboardFrameEndUserInfoKey]?.cgRectValue.size else { return } keyboardHeight = keyboardSize.height containerViewBottomLayoutConstraint.constant = -keyboardHeight UIView.animate(withDuration: 0.3) { self.view.layoutIfNeeded() } } func alertActionEnabledDidChange(_ notification: Notification) { actions.forEach { $0.button.isEnabled = $0.isEnabled } } } // MARK: - UIViewControllerTransitioningDelegate extension PCLBlurEffectAlertController: UIViewControllerTransitioningDelegate { public func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? { return PCLBlurEffectAlertTransitionAnimator(present: true) } public func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? { return PCLBlurEffectAlertTransitionAnimator(present: false) } } // MARK: - UIApplication private extension UIApplication { var topViewController: UIViewController? { guard var topViewController = UIApplication.shared.keyWindow?.rootViewController else { return nil } while let presentedViewController = topViewController.presentedViewController { topViewController = presentedViewController } return topViewController } } ================================================ FILE: Sources/PCLBlurEffectAlert+TransitionAnimator.swift ================================================ // // PCLBlurEffectAlertController+Tr.swift // PCLBlurEffectAlert // // Created by hiroyuki yoshida on 2017/02/26. // // import UIKit public typealias PCLBlurEffectAlertTransitionAnimator = PCLBlurEffectAlert.TransitionAnimator extension PCLBlurEffectAlert { // MARK: - TransitionAnimator open class TransitionAnimator: NSObject, UIViewControllerAnimatedTransitioning { fileprivate typealias TransitionAnimator = PCLBlurEffectAlert.TransitionAnimator fileprivate static let presentBackAnimationDuration: TimeInterval = 0.45 fileprivate static let dismissBackAnimationDuration: TimeInterval = 0.35 fileprivate var goingPresent: Bool! init(present: Bool) { super.init() goingPresent = present } open func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval { if goingPresent == true { return TransitionAnimator.presentBackAnimationDuration } else { return TransitionAnimator.dismissBackAnimationDuration } } open func animateTransition(using transitionContext: UIViewControllerContextTransitioning) { if goingPresent == true { presentAnimation(transitionContext) } else { dismissAnimation(transitionContext) } } } } // MARK: - Extension private extension PCLBlurEffectAlert.TransitionAnimator { func presentAnimation(_ transitionContext: UIViewControllerContextTransitioning) { guard let alertController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to) as? PCLBlurEffectAlertController else { transitionContext.completeTransition(false) return } let containerView = transitionContext.containerView containerView.backgroundColor = .clear containerView.addSubview(alertController.view) alertController.overlayView.alpha = 0 let animations: (() -> Void) switch alertController.style { case .actionSheet: alertController.alertView.transform = CGAffineTransform(translationX: 0, y: alertController.alertView.frame.height) animations = { alertController.overlayView.alpha = 1 alertController.alertView.transform = CGAffineTransform(translationX: 0, y: -10) } default: alertController.cornerView.subviews.forEach { $0.alpha = 0 } alertController.alertView.center = alertController.view.center alertController.alertView.transform = CGAffineTransform(scaleX: 0.5, y: 0.5) animations = { alertController.overlayView.alpha = 1 alertController.cornerView.subviews.forEach { $0.alpha = 1 } alertController.alertView.transform = CGAffineTransform(scaleX: 1.05, y: 1.05) } } UIView.animate(withDuration: transitionDuration(using: transitionContext) * (5 / 9), animations: animations) { finished in guard finished else { return } let animations = { alertController.alertView.transform = CGAffineTransform.identity } UIView.animate(withDuration: self.transitionDuration(using: transitionContext) * (4 / 9), animations: animations) { finished in guard finished else { return } let cancelled = transitionContext.transitionWasCancelled if cancelled { alertController.view.removeFromSuperview() } transitionContext.completeTransition(!cancelled) } } } func dismissAnimation(_ transitionContext: UIViewControllerContextTransitioning) { guard let alertController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from) as? PCLBlurEffectAlertController else { transitionContext.completeTransition(false) return } let animations = { alertController.overlayView.alpha = 0 switch alertController.style { case .actionSheet: alertController.containerView.transform = CGAffineTransform(translationX: 0, y: alertController.alertView.frame.height) default: alertController.alertView.transform = CGAffineTransform(scaleX: 0.8, y: 0.8) alertController.cornerView.subviews.forEach { $0.alpha = 0 } } } UIView.animate(withDuration: transitionDuration(using: transitionContext), delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: 0, options: UIViewAnimationOptions(), animations: animations) { finished in guard finished else { return } transitionContext.completeTransition(!transitionContext.transitionWasCancelled) } } } ================================================ FILE: Sources/PCLBlurEffectAlert.h ================================================ // // PCLBlurEffectAlert.h // PCLBlurEffectAlert // // Created by hiroyuki yoshida on 2016/05/11. // Copyright © 2016年 hiroyuki yoshida. All rights reserved. // #import //! Project version number for PCLBlurEffectAlert. FOUNDATION_EXPORT double PCLBlurEffectAlertVersionNumber; //! Project version string for PCLBlurEffectAlert. FOUNDATION_EXPORT const unsigned char PCLBlurEffectAlertVersionString[]; // In this header, you should import all the public headers of your framework using statements like #import ================================================ FILE: Sources/PCLBlurEffectAlert.swift ================================================ // // PCLBlurEffectAlert.swift // Pods // // Created by hryk224 on 2015/10/14. // // import UIKit open class PCLBlurEffectAlert { public enum ActionStyle { case `default`, cancel, destructive var isCancel: Bool { return self == .cancel } } public enum ControllerStyle { case actionSheet, alert, alertVertical } } // MARK: - RespondsView extension PCLBlurEffectAlert { final class RespondsView: UIView { weak var delegate: PCLRespondsViewDelegate? required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) } override init(frame: CGRect) { super.init(frame: frame) } override func touchesEnded(_ touches: Set, with event: UIEvent?) { super.touchesEnded(touches, with: event) delegate?.respondsViewDidTouch(self) } } } // MARK: - PCLRespondsViewDelegate protocol PCLRespondsViewDelegate: class { func respondsViewDidTouch(_ view: UIView) } // MARK: - NotificationManager extension PCLBlurEffectAlert { struct NotificationManager { static let shared = PCLBlurEffectAlert.NotificationManager() fileprivate let notificationCenter = NotificationCenter.default } } // MARK: - keyboardWillShow/Hide @objc protocol PCLAlertKeyboardNotificationObserver: class { func keyboardWillShow(_ notification: Notification) func keyboardWillHide(_ notification: Notification) } extension PCLBlurEffectAlert.NotificationManager { func addKeyboardNotificationObserver(_ observer: PCLAlertKeyboardNotificationObserver) { notificationCenter.addObserver(observer, selector: #selector(PCLAlertKeyboardNotificationObserver.keyboardWillShow(_:)), name: Notification.Name.UIKeyboardWillShow, object: nil) notificationCenter.addObserver(observer, selector: #selector(PCLAlertKeyboardNotificationObserver.keyboardWillHide(_:)), name: Notification.Name.UIKeyboardWillHide, object: nil) } func removeKeyboardNotificationObserver(_ observer: PCLAlertKeyboardNotificationObserver) { notificationCenter.removeObserver(observer, name: Notification.Name.UIKeyboardWillShow, object: nil) notificationCenter.removeObserver(observer, name: Notification.Name.UIKeyboardWillHide, object: nil) } func postKeyboardWillShowNotification() { notificationCenter.post(Notification(name: Notification.Name.UIKeyboardWillShow, object: nil)) } func postKeyboardWillHideNotification() { notificationCenter.post(Notification(name: Notification.Name.UIKeyboardWillHide, object: nil)) } } // MARK: - AlertActionEnabledDidChange @objc protocol PCLAlertActionEnabledDidChangeNotificationObserver: class { func alertActionEnabledDidChange(_ notification: Notification) } // MARK: - private extension PCLBlurEffectAlert.NotificationManager { private typealias Manager = PCLBlurEffectAlert.NotificationManager private static let AlertActionEnabledDidChangeNotification = "AlertActionEnabledDidChangeNotification" func addAlertActionEnabledDidChangeNotificationObserver(_ observer: PCLAlertActionEnabledDidChangeNotificationObserver) { notificationCenter.addObserver(observer, selector: #selector(PCLAlertActionEnabledDidChangeNotificationObserver.alertActionEnabledDidChange(_:)), name: Notification.Name(rawValue: Manager.AlertActionEnabledDidChangeNotification), object: nil) } func removeAlertActionEnabledDidChangeNotificationObserver(_ observer: PCLAlertActionEnabledDidChangeNotificationObserver) { notificationCenter.removeObserver(observer, name: Notification.Name(rawValue: Manager.AlertActionEnabledDidChangeNotification), object: nil) } func postAlertActionEnabledDidChangeNotification() { notificationCenter.post(Notification(name: Notification.Name(rawValue: Manager.AlertActionEnabledDidChangeNotification), object: nil, userInfo: nil)) } }