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 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 a99a7e8..a6d5507 100644 --- a/HELargeCenterTabBarController/HELargeCenterTabBarController.swift +++ b/HELargeCenterTabBarController/HELargeCenterTabBarController.swift @@ -144,20 +144,20 @@ class HELargeCenterTabBarController: UITabBarController { let button = UIButton(type: .custom) button.translatesAutoresizingMaskIntoConstraints = false tabBar.addSubview(button) - + + let bottomAnchor: NSLayoutYAxisAnchor if #available(iOS 11.0, *) { - NSLayoutConstraint.activate([ - button.centerXAnchor.constraint(equalTo: view.centerXAnchor), - button.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor), - button.widthAnchor.constraint(equalToConstant: unselectedImage.size.width), - button.heightAnchor.constraint(equalToConstant: unselectedImage.size.height) - ]) + bottomAnchor = tabBar.safeAreaLayoutGuide.bottomAnchor } 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])) + bottomAnchor = tabBar.bottomAnchor } + + NSLayoutConstraint.activate([ + button.centerXAnchor.constraint(equalTo: tabBar.centerXAnchor), + button.bottomAnchor.constraint(equalTo: 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