From 512167425b039e48daf48b9581db59bc54acea10 Mon Sep 17 00:00:00 2001 From: mrustaa Date: Tue, 19 Apr 2022 03:49:21 +0300 Subject: [PATCH] Update target version min 9.0 --- .../project.pbxproj | 15 +- .../ButtonClickStyle-Example.xcscheme | 111 ----------- .../xcschemes/ButtonClickStyle.xcscheme | 24 --- Example/ButtonClickStyle/AppDelegate.swift | 2 + .../Base.lproj/Main.storyboard | 32 ---- Example/ButtonClickStyle/SceneDelegate.swift | 6 + .../Button/JustPink/JustPinkButtonView.swift | 3 +- .../UI/Button/JustPink/JustPinkButtonView.xib | 4 +- .../ExampleButtonsViewController.swift | 20 +- .../ExampleAnimationsViewController.swift | 21 +- .../TestDemo/TestDemoViewController.swift | 22 ++- .../ButtonList/ButtonListViewController.swift | 20 +- .../ButtonTableListViewController.storyboard | 25 +-- .../ButtonTableListViewController.swift | 31 ++- .../ButtonLayerExampleView.xib | 2 +- .../TableAdapterView+AddRefresh.swift | 28 --- Example/Pods/Pods.xcodeproj/project.pbxproj | 180 ++---------------- .../ButtonClickStyleAnim+UIView.swift | 29 +++ .../ButtonClickStyleAnim+UIViewGlare.swift | 15 +- .../ButtonClickStyleAnim+UIViewShadow.swift | 14 +- 20 files changed, 171 insertions(+), 433 deletions(-) delete mode 100644 Example/ButtonClickStyle.xcodeproj/xcshareddata/xcschemes/ButtonClickStyle-Example.xcscheme delete mode 100644 Example/ButtonClickStyle/Utils/TableAdapterView/TableAdapterView+AddRefresh.swift create mode 100644 Sources/ButtonClickStyle/Animations/ButtonClickStyleAnim+UIView.swift diff --git a/Example/ButtonClickStyle.xcodeproj/project.pbxproj b/Example/ButtonClickStyle.xcodeproj/project.pbxproj index 744c7d1..2b14adf 100644 --- a/Example/ButtonClickStyle.xcodeproj/project.pbxproj +++ b/Example/ButtonClickStyle.xcodeproj/project.pbxproj @@ -95,7 +95,7 @@ 4A85B5DA2803EBFE00DFD435 /* TitleTextCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A85B5B92803EBFD00DFD435 /* TitleTextCell.swift */; }; 4A85B5DD2803EBFE00DFD435 /* TableAdapterView+DataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A85B5BD2803EBFD00DFD435 /* TableAdapterView+DataSource.swift */; }; 4A85B5DE2803EBFE00DFD435 /* TableAdapterView+ScrollDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A85B5BE2803EBFD00DFD435 /* TableAdapterView+ScrollDelegate.swift */; }; - 4A85B5DF2803EBFE00DFD435 /* TableAdapterView+AddRefresh.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A85B5BF2803EBFD00DFD435 /* TableAdapterView+AddRefresh.swift */; }; + 4AA6021C280E36450073E26E /* ButtonClickStyleAnim+UIView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AA6021B280E36450073E26E /* ButtonClickStyleAnim+UIView.swift */; }; 4ADE26E42803837C00634B6C /* ExampleButtonsViewController.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4ADE26E22803837C00634B6C /* ExampleButtonsViewController.storyboard */; }; 4ADE26E52803837C00634B6C /* ExampleButtonsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4ADE26E32803837C00634B6C /* ExampleButtonsViewController.swift */; }; 4ADE26E7280383DC00634B6C /* ButtonClickStyle+Buttons.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4ADE26E6280383DC00634B6C /* ButtonClickStyle+Buttons.swift */; }; @@ -198,8 +198,8 @@ 4A85B5B92803EBFD00DFD435 /* TitleTextCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TitleTextCell.swift; sourceTree = ""; }; 4A85B5BD2803EBFD00DFD435 /* TableAdapterView+DataSource.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "TableAdapterView+DataSource.swift"; sourceTree = ""; }; 4A85B5BE2803EBFD00DFD435 /* TableAdapterView+ScrollDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "TableAdapterView+ScrollDelegate.swift"; sourceTree = ""; }; - 4A85B5BF2803EBFD00DFD435 /* TableAdapterView+AddRefresh.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "TableAdapterView+AddRefresh.swift"; sourceTree = ""; }; 4A9B5AE4280B4E200033761B /* ButtonClickStyle */ = {isa = PBXFileReference; lastKnownFileType = folder; name = ButtonClickStyle; path = ..; sourceTree = ""; }; + 4AA6021B280E36450073E26E /* ButtonClickStyleAnim+UIView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ButtonClickStyleAnim+UIView.swift"; sourceTree = ""; }; 4ADE26E22803837C00634B6C /* ExampleButtonsViewController.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = ExampleButtonsViewController.storyboard; sourceTree = ""; }; 4ADE26E32803837C00634B6C /* ExampleButtonsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExampleButtonsViewController.swift; sourceTree = ""; }; 4ADE26E6280383DC00634B6C /* ButtonClickStyle+Buttons.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ButtonClickStyle+Buttons.swift"; sourceTree = ""; }; @@ -275,6 +275,7 @@ 4A477AC9280AEE280004156A /* Animations */ = { isa = PBXGroup; children = ( + 4AA6021B280E36450073E26E /* ButtonClickStyleAnim+UIView.swift */, 4A14CBD02803437C00DA8A68 /* ButtonClickStyleAnim+UIViewAlpha.swift */, 4A14CBD12803437C00DA8A68 /* ButtonClickStyleAnim+UIViewShadow.swift */, 4A14CBD22803437C00DA8A68 /* ButtonClickStyleAnim+UIViewPulsate.swift */, @@ -581,7 +582,6 @@ 4A85B5B22803EBFD00DFD435 /* TableAdapterView+UpdateRows.swift */, 4A85B5BD2803EBFD00DFD435 /* TableAdapterView+DataSource.swift */, 4A85B5BE2803EBFD00DFD435 /* TableAdapterView+ScrollDelegate.swift */, - 4A85B5BF2803EBFD00DFD435 /* TableAdapterView+AddRefresh.swift */, ); path = TableAdapterView; sourceTree = ""; @@ -890,7 +890,6 @@ 4ADE26E7280383DC00634B6C /* ButtonClickStyle+Buttons.swift in Sources */, 4A62F3992803115C00534ABA /* BtnView.swift in Sources */, 607FACD81AFB9204008FA782 /* ViewController.swift in Sources */, - 4A85B5DF2803EBFE00DFD435 /* TableAdapterView+AddRefresh.swift in Sources */, 4A85B5A82803EBA400DFD435 /* ButtonListCell.swift in Sources */, 4A85B5D02803EBFE00DFD435 /* TableAdapterView+AddGradient.swift in Sources */, 4A62F3752803115C00534ABA /* StoryboardController.swift in Sources */, @@ -929,6 +928,7 @@ 4A62F39F2803115C00534ABA /* TestDemoViewController.swift in Sources */, 4A62F3802803115C00534ABA /* BlueButtonView.swift in Sources */, 4A62F3842803115C00534ABA /* TestDemoBlurButtonView.swift in Sources */, + 4AA6021C280E36450073E26E /* ButtonClickStyleAnim+UIView.swift in Sources */, 4A231B7A280A82250073284C /* ButtonClickStyleEmoji.swift in Sources */, 607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */, 4A62F3952803115C00534ABA /* NeomorphismButtonView.swift in Sources */, @@ -1006,7 +1006,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 14.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -1056,8 +1056,9 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 14.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = NO; + ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; VALIDATE_PRODUCT = YES; @@ -1073,6 +1074,7 @@ CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = Y7546NLJW9; INFOPLIST_FILE = ButtonClickStyle/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; MARKETING_VERSION = 1.2.2; MODULE_NAME = ExampleApp; @@ -1094,6 +1096,7 @@ CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = Y7546NLJW9; INFOPLIST_FILE = ButtonClickStyle/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; MARKETING_VERSION = 1.2.2; MODULE_NAME = ExampleApp; diff --git a/Example/ButtonClickStyle.xcodeproj/xcshareddata/xcschemes/ButtonClickStyle-Example.xcscheme b/Example/ButtonClickStyle.xcodeproj/xcshareddata/xcschemes/ButtonClickStyle-Example.xcscheme deleted file mode 100644 index a84f927..0000000 --- a/Example/ButtonClickStyle.xcodeproj/xcshareddata/xcschemes/ButtonClickStyle-Example.xcscheme +++ /dev/null @@ -1,111 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Example/ButtonClickStyle.xcodeproj/xcshareddata/xcschemes/ButtonClickStyle.xcscheme b/Example/ButtonClickStyle.xcodeproj/xcshareddata/xcschemes/ButtonClickStyle.xcscheme index a84f927..0b6fef6 100644 --- a/Example/ButtonClickStyle.xcodeproj/xcshareddata/xcschemes/ButtonClickStyle.xcscheme +++ b/Example/ButtonClickStyle.xcodeproj/xcshareddata/xcschemes/ButtonClickStyle.xcscheme @@ -20,20 +20,6 @@ ReferencedContainer = "container:ButtonClickStyle.xcodeproj"> - - - - - - - - UISceneConfiguration { // Called when a new scene session is being created. // Use this method to select a configuration to create the new scene with. return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) } + @available(iOS 13.0, *) func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { // Called when the user discards a scene session. // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. diff --git a/Example/ButtonClickStyle/Base.lproj/Main.storyboard b/Example/ButtonClickStyle/Base.lproj/Main.storyboard index 5199bb6..ec5281a 100644 --- a/Example/ButtonClickStyle/Base.lproj/Main.storyboard +++ b/Example/ButtonClickStyle/Base.lproj/Main.storyboard @@ -141,32 +141,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -210,11 +184,5 @@ - - - - - - diff --git a/Example/ButtonClickStyle/SceneDelegate.swift b/Example/ButtonClickStyle/SceneDelegate.swift index 9293f89..ac4f060 100644 --- a/Example/ButtonClickStyle/SceneDelegate.swift +++ b/Example/ButtonClickStyle/SceneDelegate.swift @@ -11,6 +11,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { var window: UIWindow? + @available(iOS 13.0, *) func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. @@ -30,6 +31,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { } + @available(iOS 13.0, *) func sceneDidDisconnect(_ scene: UIScene) { // Called as the scene is being released by the system. // This occurs shortly after the scene enters the background, or when its session is discarded. @@ -37,21 +39,25 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). } + @available(iOS 13.0, *) func sceneDidBecomeActive(_ scene: UIScene) { // Called when the scene has moved from an inactive state to an active state. // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. } + @available(iOS 13.0, *) func sceneWillResignActive(_ scene: UIScene) { // Called when the scene will move from an active state to an inactive state. // This may occur due to temporary interruptions (ex. an incoming phone call). } + @available(iOS 13.0, *) func sceneWillEnterForeground(_ scene: UIScene) { // Called as the scene transitions from the background to the foreground. // Use this method to undo the changes made on entering the background. } + @available(iOS 13.0, *) func sceneDidEnterBackground(_ scene: UIScene) { // Called as the scene transitions from the foreground to the background. // Use this method to save data, release shared resources, and store enough scene-specific state information diff --git a/Example/ButtonClickStyle/UI/Button/JustPink/JustPinkButtonView.swift b/Example/ButtonClickStyle/UI/Button/JustPink/JustPinkButtonView.swift index 680c90f..59dbec4 100644 --- a/Example/ButtonClickStyle/UI/Button/JustPink/JustPinkButtonView.swift +++ b/Example/ButtonClickStyle/UI/Button/JustPink/JustPinkButtonView.swift @@ -49,7 +49,8 @@ class JustPinkButtonView: BtnView { views = [subMainView] } else { - fillView.fillColor = .systemGray5.withAlphaComponent(0.55) + + fillView.fillColor = #colorLiteral(red: 0.8980392157, green: 0.8980392157, blue: 0.9176470588, alpha: 1).withAlphaComponent(0.55) gradientView.isHidden = false gradientView.alpha = 1 mainShadowView.blur = 24 diff --git a/Example/ButtonClickStyle/UI/Button/JustPink/JustPinkButtonView.xib b/Example/ButtonClickStyle/UI/Button/JustPink/JustPinkButtonView.xib index 5aebc6c..a39408a 100644 --- a/Example/ButtonClickStyle/UI/Button/JustPink/JustPinkButtonView.xib +++ b/Example/ButtonClickStyle/UI/Button/JustPink/JustPinkButtonView.xib @@ -22,10 +22,10 @@ - + - + diff --git a/Example/ButtonClickStyle/UI/ScreenIPad/ExampleButtons/ExampleButtonsViewController.swift b/Example/ButtonClickStyle/UI/ScreenIPad/ExampleButtons/ExampleButtonsViewController.swift index 372024e..d1d5289 100644 --- a/Example/ButtonClickStyle/UI/ScreenIPad/ExampleButtons/ExampleButtonsViewController.swift +++ b/Example/ButtonClickStyle/UI/ScreenIPad/ExampleButtons/ExampleButtonsViewController.swift @@ -7,7 +7,6 @@ class ExampleButtonsViewController: StoryboardController { var colorChanging: Bool = false @IBOutlet var colorButtonClickStyleDesignView: ButtonClickStyleDesignView! var colorSelected: UIColor? - let colorPicker = UIColorPickerViewController() @IBOutlet var allSubviewsSwitch: UISwitch! @IBOutlet var addBackgroundColorSwitch: UISwitch! @@ -27,7 +26,6 @@ class ExampleButtonsViewController: StoryboardController { override func viewDidLoad() { super.viewDidLoad() - colorPicker.delegate = self // title = "Click Style Animations" @@ -113,7 +111,21 @@ class ExampleButtonsViewController: StoryboardController { @IBAction func colorPickerAction(_ sender: Any) { resetAllColorChangeFlags() colorChanging = true - present(colorPicker, animated: true, completion: nil) + if #available(iOS 14.0, *) { + let colorPicker = UIColorPickerViewController() + colorPicker.delegate = self + present(colorPicker, animated: true, completion: nil) + } else { + colorNotPicker() + } + } + + func colorNotPicker() { + colorSelected = UIColor.random() + update() + colorButtonClickStyleDesignView.fillColor = colorSelected + colorButtonClickStyleDesignView.setNeedsLayout() + resetAllColorChangeFlags() } @objc func allSubviewsSwitchAction(swtch: UISwitch, event: UIEvent) { @@ -223,6 +235,7 @@ class ExampleButtonsViewController: StoryboardController { extension ExampleButtonsViewController: UIColorPickerViewControllerDelegate { + @available(iOS 14.0, *) func colorPickerViewControllerDidSelectColor(_ viewController: UIColorPickerViewController) { if colorChanging @@ -231,6 +244,7 @@ extension ExampleButtonsViewController: UIColorPickerViewControllerDelegate { } } + @available(iOS 14.0, *) func colorPickerViewControllerDidFinish(_ viewController: UIColorPickerViewController) { update() diff --git a/Example/ButtonClickStyle/UI/ScreenIPad/ExampleClickStyleAnimations/ExampleAnimationsViewController.swift b/Example/ButtonClickStyle/UI/ScreenIPad/ExampleClickStyleAnimations/ExampleAnimationsViewController.swift index 3a670eb..6d9e267 100644 --- a/Example/ButtonClickStyle/UI/ScreenIPad/ExampleClickStyleAnimations/ExampleAnimationsViewController.swift +++ b/Example/ButtonClickStyle/UI/ScreenIPad/ExampleClickStyleAnimations/ExampleAnimationsViewController.swift @@ -7,7 +7,6 @@ class ExampleAnimationsViewController: StoryboardController { var colorChanging: Bool = false @IBOutlet var colorButtonClickStyleDesignView: ButtonClickStyleDesignView! var colorSelected: UIColor? - let colorPicker = UIColorPickerViewController() @IBOutlet var allSubviewsSwitch: UISwitch! @IBOutlet var addBackgroundColorSwitch: UISwitch! @@ -26,8 +25,6 @@ class ExampleAnimationsViewController: StoryboardController { override func viewDidLoad() { super.viewDidLoad() - colorPicker.delegate = self - // title = "Click Style Animations" buttonTypes = ButtonClick.Style.allNameFull @@ -108,7 +105,21 @@ class ExampleAnimationsViewController: StoryboardController { @IBAction func colorPickerAction(_ sender: Any) { resetAllColorChangeFlags() colorChanging = true - present(colorPicker, animated: true, completion: nil) + if #available(iOS 14.0, *) { + let colorPicker = UIColorPickerViewController() + colorPicker.delegate = self + present(colorPicker, animated: true, completion: nil) + } else { + colorNotPicker() + } + } + + func colorNotPicker() { + colorSelected = UIColor.random() + update() + colorButtonClickStyleDesignView.fillColor = colorSelected + colorButtonClickStyleDesignView.setNeedsLayout() + resetAllColorChangeFlags() } @objc func allSubviewsSwitchAction(swtch: UISwitch, event: UIEvent) { @@ -272,6 +283,7 @@ class ExampleAnimationsViewController: StoryboardController { extension ExampleAnimationsViewController: UIColorPickerViewControllerDelegate { + @available(iOS 14.0, *) func colorPickerViewControllerDidSelectColor(_ viewController: UIColorPickerViewController) { if colorChanging @@ -280,6 +292,7 @@ extension ExampleAnimationsViewController: UIColorPickerViewControllerDelegate { } } + @available(iOS 14.0, *) func colorPickerViewControllerDidFinish(_ viewController: UIColorPickerViewController) { update() diff --git a/Example/ButtonClickStyle/UI/ScreenIPad/TestDemo/TestDemoViewController.swift b/Example/ButtonClickStyle/UI/ScreenIPad/TestDemo/TestDemoViewController.swift index d68cb3a..6cddaf8 100644 --- a/Example/ButtonClickStyle/UI/ScreenIPad/TestDemo/TestDemoViewController.swift +++ b/Example/ButtonClickStyle/UI/ScreenIPad/TestDemo/TestDemoViewController.swift @@ -7,7 +7,6 @@ class TestDemoViewController: StoryboardController { var colorChanging: Bool = false @IBOutlet var colorButtonClickStyleDesignView: ButtonClickStyleDesignView! var colorSelected: UIColor? - let colorPicker = UIColorPickerViewController() @IBOutlet var allSubviewsSwitch: UISwitch! @IBOutlet var addBackgroundColorSwitch: UISwitch! @@ -26,7 +25,6 @@ class TestDemoViewController: StoryboardController { override func viewDidLoad() { super.viewDidLoad() - colorPicker.delegate = self title = "Test Demo" @@ -107,7 +105,22 @@ class TestDemoViewController: StoryboardController { @IBAction func colorPickerAction(_ sender: Any) { resetAllColorChangeFlags() colorChanging = true - present(colorPicker, animated: true, completion: nil) + + if #available(iOS 14.0, *) { + let colorPicker = UIColorPickerViewController() + colorPicker.delegate = self + present(colorPicker, animated: true, completion: nil) + } else { + colorNotPicker() + } + } + + func colorNotPicker() { + colorSelected = UIColor.random() + update() + colorButtonClickStyleDesignView.fillColor = colorSelected + colorButtonClickStyleDesignView.setNeedsLayout() + resetAllColorChangeFlags() } @objc func allSubviewsSwitchAction(swtch: UISwitch, event: UIEvent) { @@ -136,7 +149,6 @@ class TestDemoViewController: StoryboardController { if let touchEvent = event.allTouches?.first { switch touchEvent.phase { case .ended: -// updateButtons() update() default: break @@ -193,6 +205,7 @@ class TestDemoViewController: StoryboardController { extension TestDemoViewController: UIColorPickerViewControllerDelegate { + @available(iOS 14.0, *) func colorPickerViewControllerDidSelectColor(_ viewController: UIColorPickerViewController) { if colorChanging @@ -201,6 +214,7 @@ extension TestDemoViewController: UIColorPickerViewControllerDelegate { } } + @available(iOS 14.0, *) func colorPickerViewControllerDidFinish(_ viewController: UIColorPickerViewController) { update() diff --git a/Example/ButtonClickStyle/UI/ScreenIPhone/ButtonList/ButtonListViewController.swift b/Example/ButtonClickStyle/UI/ScreenIPhone/ButtonList/ButtonListViewController.swift index 44ff6d0..01036b5 100644 --- a/Example/ButtonClickStyle/UI/ScreenIPhone/ButtonList/ButtonListViewController.swift +++ b/Example/ButtonClickStyle/UI/ScreenIPhone/ButtonList/ButtonListViewController.swift @@ -28,7 +28,6 @@ class ButtonListViewController: StoryboardController { var colorChanging: Bool = false @IBOutlet var colorButtonClickStyleDesignView: ButtonClickStyleDesignView! var colorSelected: UIColor? - let colorPicker = UIColorPickerViewController() let buttonTypes = ButtonClick.Buttons.allNameFull @@ -36,7 +35,21 @@ class ButtonListViewController: StoryboardController { @IBAction func colorPickerAction(_ sender: Any) { resetAllColorChangeFlags() colorChanging = true - present(colorPicker, animated: true, completion: nil) + if #available(iOS 14.0, *) { + let colorPicker = UIColorPickerViewController() + colorPicker.delegate = self + present(colorPicker, animated: true, completion: nil) + } else { + colorNotPicker() + } + } + + func colorNotPicker() { + colorSelected = UIColor.random() + updateButtons() + colorButtonClickStyleDesignView.fillColor = colorSelected + colorButtonClickStyleDesignView.setNeedsLayout() + resetAllColorChangeFlags() } @IBAction func buttonColorClear(_ sender: Any) { @@ -73,7 +86,6 @@ class ButtonListViewController: StoryboardController { title = "One Button Customizable" - colorPicker.delegate = self animationValueSlider.addTarget(self, action: #selector(onSliderValChanged(slider:event:)), for: .valueChanged) @@ -276,6 +288,7 @@ extension ButtonListViewController: UIPickerViewDelegate { extension ButtonListViewController: UIColorPickerViewControllerDelegate { + @available(iOS 14.0, *) func colorPickerViewControllerDidSelectColor(_ viewController: UIColorPickerViewController) { if colorChanging @@ -285,6 +298,7 @@ extension ButtonListViewController: UIColorPickerViewControllerDelegate { colorClearButton.isHidden = (colorSelected == nil) || (colorSelected == .clear) } + @available(iOS 14.0, *) func colorPickerViewControllerDidFinish(_ viewController: UIColorPickerViewController) { updateButtons() diff --git a/Example/ButtonClickStyle/UI/ScreenIPhone/ButtonTableList/ButtonTableListViewController.storyboard b/Example/ButtonClickStyle/UI/ScreenIPhone/ButtonTableList/ButtonTableListViewController.storyboard index ae3d774..5159c34 100644 --- a/Example/ButtonClickStyle/UI/ScreenIPhone/ButtonTableList/ButtonTableListViewController.storyboard +++ b/Example/ButtonClickStyle/UI/ScreenIPhone/ButtonTableList/ButtonTableListViewController.storyboard @@ -37,7 +37,7 @@ - + @@ -147,7 +147,7 @@ - +