From e2c4ccd273da49e98e0c4126021524edc32ece80 Mon Sep 17 00:00:00 2001 From: dodgecm Date: Mon, 9 Oct 2017 21:11:59 -0400 Subject: [PATCH 1/4] Fixing disappearing constraint issue. --- .../HELargeCenterTabBarController.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/HELargeCenterTabBarController/HELargeCenterTabBarController.swift b/HELargeCenterTabBarController/HELargeCenterTabBarController.swift index a99a7e8..14d8c51 100644 --- a/HELargeCenterTabBarController/HELargeCenterTabBarController.swift +++ b/HELargeCenterTabBarController/HELargeCenterTabBarController.swift @@ -145,10 +145,10 @@ class HELargeCenterTabBarController: UITabBarController { button.translatesAutoresizingMaskIntoConstraints = false tabBar.addSubview(button) - if #available(iOS 11.0, *) { + if #available(iOS 9.0, *) { NSLayoutConstraint.activate([ - button.centerXAnchor.constraint(equalTo: view.centerXAnchor), - button.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor), + button.centerXAnchor.constraint(equalTo: tabBar.centerXAnchor), + button.bottomAnchor.constraint(equalTo: tabBar.bottomAnchor), button.widthAnchor.constraint(equalToConstant: unselectedImage.size.width), button.heightAnchor.constraint(equalToConstant: unselectedImage.size.height) ]) From 09886c2ebade3b5a0d045e09d3a31bf144c3a0d8 Mon Sep 17 00:00:00 2001 From: dodgecm Date: Sun, 15 Oct 2017 15:48:28 -0400 Subject: [PATCH 2/4] Changing iOS deployment target to 9.0 --- .../project.pbxproj | 4 ++-- .../HELargeCenterTabBarController.swift | 19 ++++++------------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/HELargeCenterTabBarController.xcodeproj/project.pbxproj b/HELargeCenterTabBarController.xcodeproj/project.pbxproj index 24101c0..ae69c94 100644 --- a/HELargeCenterTabBarController.xcodeproj/project.pbxproj +++ b/HELargeCenterTabBarController.xcodeproj/project.pbxproj @@ -378,7 +378,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; RUN_CLANG_STATIC_ANALYZER = YES; @@ -430,7 +430,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = NO; RUN_CLANG_STATIC_ANALYZER = YES; SDKROOT = iphoneos; diff --git a/HELargeCenterTabBarController/HELargeCenterTabBarController.swift b/HELargeCenterTabBarController/HELargeCenterTabBarController.swift index 14d8c51..4bd9b8c 100644 --- a/HELargeCenterTabBarController/HELargeCenterTabBarController.swift +++ b/HELargeCenterTabBarController/HELargeCenterTabBarController.swift @@ -145,19 +145,12 @@ class HELargeCenterTabBarController: UITabBarController { button.translatesAutoresizingMaskIntoConstraints = false tabBar.addSubview(button) - if #available(iOS 9.0, *) { - NSLayoutConstraint.activate([ - button.centerXAnchor.constraint(equalTo: tabBar.centerXAnchor), - button.bottomAnchor.constraint(equalTo: tabBar.bottomAnchor), - button.widthAnchor.constraint(equalToConstant: unselectedImage.size.width), - button.heightAnchor.constraint(equalToConstant: unselectedImage.size.height) - ]) - } else { - view.addConstraint(NSLayoutConstraint(item: button, attribute: NSLayoutAttribute.centerX, relatedBy: NSLayoutRelation.equal, toItem: view, attribute: NSLayoutAttribute.centerX, multiplier: 1.0, constant: 0.0)) - view.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:[button]-0-|", options: NSLayoutFormatOptions(rawValue: 0), metrics: nil, views: ["button": button])); - view.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:[button(==\(unselectedImage.size.width))]", options: NSLayoutFormatOptions(rawValue: 0), metrics: nil, views: ["button": button])) - view.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:[button(==\(unselectedImage.size.height))]", options: NSLayoutFormatOptions(rawValue: 0), metrics: nil, views: ["button": button])) - } + NSLayoutConstraint.activate([ + button.centerXAnchor.constraint(equalTo: tabBar.centerXAnchor), + button.bottomAnchor.constraint(equalTo: tabBar.bottomAnchor), + button.widthAnchor.constraint(equalToConstant: unselectedImage.size.width), + button.heightAnchor.constraint(equalToConstant: unselectedImage.size.height) + ]) button.addTarget(self, action: #selector(centerButtonAction(_:)), for: .touchUpInside) centerButton = button From c298ebc7eaad995fca510cb8466ad841d6c404be Mon Sep 17 00:00:00 2001 From: dodgecm Date: Thu, 2 Nov 2017 13:20:53 -0700 Subject: [PATCH 3/4] Updating podspec --- HELargeCenterTabBarController.podspec | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/HELargeCenterTabBarController.podspec b/HELargeCenterTabBarController.podspec index 94060a4..7f754c0 100644 --- a/HELargeCenterTabBarController.podspec +++ b/HELargeCenterTabBarController.podspec @@ -7,14 +7,14 @@ Pod::Spec.new do |spec| spec.author = { 'John C. Daub (@hsoi)' => 'hsoi@hsoienterprises.com' } spec.social_media_url = 'https://twitter.com/hsoienterprises' spec.description = <<-DESC - HELargeCenterTabBarController is a 100% Swift implementation of a UITabBarController with a lager center tab. + HELargeCenterTabBarController is a 100% Swift implementation of a UITabBarController with a lager center tab. The center tab can be used in the typical manner where a tap switches to display the associated ViewController, or the center tab can be used in an alternate manner where the tap does not switch ViewControllers but instead executes a target-action. - + Simple. Lightweight. To-the-point. DESC spec.requires_arc = true spec.license = { :type => 'BSD 3-clause “New” or “Revised”', :file => 'LICENSE' } spec.source_files = ['HELargeCenterTabBarController/*.swift', 'HELargeCenterTabBarController/*.h'] - spec.platform = :ios, '8.0' + spec.platform = :ios, '9.0' spec.module_name = 'HELargeCenterTabBarController' end From e98d012ef926adf77d505393e83c2da1748a3206 Mon Sep 17 00:00:00 2001 From: dodgecm Date: Tue, 12 Dec 2017 14:32:36 -0500 Subject: [PATCH 4/4] Fixing an issue where the center button would be misaligned on iPhone X devices --- .../HELargeCenterTabBarController.swift | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/HELargeCenterTabBarController/HELargeCenterTabBarController.swift b/HELargeCenterTabBarController/HELargeCenterTabBarController.swift index 4bd9b8c..a6d5507 100644 --- a/HELargeCenterTabBarController/HELargeCenterTabBarController.swift +++ b/HELargeCenterTabBarController/HELargeCenterTabBarController.swift @@ -144,10 +144,17 @@ class HELargeCenterTabBarController: UITabBarController { let button = UIButton(type: .custom) button.translatesAutoresizingMaskIntoConstraints = false tabBar.addSubview(button) - + + let bottomAnchor: NSLayoutYAxisAnchor + if #available(iOS 11.0, *) { + bottomAnchor = tabBar.safeAreaLayoutGuide.bottomAnchor + } else { + bottomAnchor = tabBar.bottomAnchor + } + NSLayoutConstraint.activate([ button.centerXAnchor.constraint(equalTo: tabBar.centerXAnchor), - button.bottomAnchor.constraint(equalTo: tabBar.bottomAnchor), + button.bottomAnchor.constraint(equalTo: bottomAnchor), button.widthAnchor.constraint(equalToConstant: unselectedImage.size.width), button.heightAnchor.constraint(equalToConstant: unselectedImage.size.height) ])