diff --git a/IQKeyboardManager.podspec.json b/IQKeyboardManager.podspec.json index 51fafcc0..7de7f402 100644 --- a/IQKeyboardManager.podspec.json +++ b/IQKeyboardManager.podspec.json @@ -1,9 +1,9 @@ { "name": "IQKeyboardManager", - "version": "5.0.1", + "version": "5.0.2", "source": { "git": "https://github.com/hackiftekhar/IQKeyboardManager.git", - "tag": "v5.0.1" + "tag": "v5.0.2" }, "summary": "Codeless drop-in universal library allows to prevent issues of keyboard sliding up and cover UITextField/UITextView.", "homepage": "https://github.com/hackiftekhar/IQKeyboardManager", diff --git a/IQKeyboardManager/IQToolbar/IQBarButtonItem.m b/IQKeyboardManager/IQToolbar/IQBarButtonItem.m index 843e014a..35734e11 100644 --- a/IQKeyboardManager/IQToolbar/IQBarButtonItem.m +++ b/IQKeyboardManager/IQToolbar/IQBarButtonItem.m @@ -50,7 +50,7 @@ +(void)initialize { UIControlState controlState = [state unsignedIntegerValue]; - [appearanceProxy setTitleTextAttributes:@{ NSFontAttributeName: [UIFont systemFontOfSize:15.0], NSForegroundColorAttributeName: [UIColor redColor] } forState:controlState]; + [appearanceProxy setTitleTextAttributes:nil forState:controlState]; [appearanceProxy setBackgroundImage:nil forState:controlState barMetrics:UIBarMetricsDefault]; [appearanceProxy setBackgroundImage:nil forState:controlState style:UIBarButtonItemStyleDone barMetrics:UIBarMetricsDefault]; [appearanceProxy setBackgroundImage:nil forState:controlState style:UIBarButtonItemStylePlain barMetrics:UIBarMetricsDefault]; diff --git a/IQKeyboardManagerSwift.podspec.json b/IQKeyboardManagerSwift.podspec.json index 814555db..83602932 100644 --- a/IQKeyboardManagerSwift.podspec.json +++ b/IQKeyboardManagerSwift.podspec.json @@ -1,9 +1,9 @@ { "name": "IQKeyboardManagerSwift", - "version": "5.0.1", + "version": "5.0.2", "source": { "git": "https://github.com/hackiftekhar/IQKeyboardManager.git", - "tag": "v5.0.1" + "tag": "v5.0.2" }, "summary": "Codeless drop-in universal library allows to prevent issues of keyboard sliding up and cover UITextField/UITextView.", "homepage": "https://github.com/hackiftekhar/IQKeyboardManager", diff --git a/IQKeyboardManagerSwift/IQToolbar/IQBarButtonItem.swift b/IQKeyboardManagerSwift/IQToolbar/IQBarButtonItem.swift index a9c05a73..7d95ed93 100644 --- a/IQKeyboardManagerSwift/IQToolbar/IQBarButtonItem.swift +++ b/IQKeyboardManagerSwift/IQToolbar/IQBarButtonItem.swift @@ -41,51 +41,26 @@ open class IQBarButtonItem: UIBarButtonItem { private class func classInitialize() { - //Tint color - self.appearance().tintColor = nil + let appearanceProxy = self.appearance() - //Title - self.appearance().setTitlePositionAdjustment(UIOffset.zero, for: UIBarMetrics.default) - self.appearance().setTitleTextAttributes(nil, for: UIControlState()) - self.appearance().setTitleTextAttributes(nil, for: UIControlState.highlighted) - self.appearance().setTitleTextAttributes(nil, for: UIControlState.disabled) - self.appearance().setTitleTextAttributes(nil, for: UIControlState.selected) - self.appearance().setTitleTextAttributes(nil, for: UIControlState.application) - self.appearance().setTitleTextAttributes(nil, for: UIControlState.reserved) + let states : [UIControlState] = [.normal,.highlighted,.disabled,.selected,.application,.reserved]; - //Background Image - self.appearance().setBackgroundImage(nil, for: UIControlState(), barMetrics: UIBarMetrics.default) - self.appearance().setBackgroundImage(nil, for: UIControlState.highlighted, barMetrics: UIBarMetrics.default) - self.appearance().setBackgroundImage(nil, for: UIControlState.disabled, barMetrics: UIBarMetrics.default) - self.appearance().setBackgroundImage(nil, for: UIControlState.selected, barMetrics: UIBarMetrics.default) - self.appearance().setBackgroundImage(nil, for: UIControlState.application, barMetrics: UIBarMetrics.default) - self.appearance().setBackgroundImage(nil, for: UIControlState.reserved, barMetrics: UIBarMetrics.default) - - self.appearance().setBackgroundImage(nil, for: UIControlState(), style: UIBarButtonItemStyle.done, barMetrics: UIBarMetrics.default) - self.appearance().setBackgroundImage(nil, for: UIControlState.highlighted, style: UIBarButtonItemStyle.done, barMetrics: UIBarMetrics.default) - self.appearance().setBackgroundImage(nil, for: UIControlState.disabled, style: UIBarButtonItemStyle.done, barMetrics: UIBarMetrics.default) - self.appearance().setBackgroundImage(nil, for: UIControlState.selected, style: UIBarButtonItemStyle.done, barMetrics: UIBarMetrics.default) - self.appearance().setBackgroundImage(nil, for: UIControlState.application, style: UIBarButtonItemStyle.done, barMetrics: UIBarMetrics.default) - self.appearance().setBackgroundImage(nil, for: UIControlState.reserved, style: UIBarButtonItemStyle.done, barMetrics: UIBarMetrics.default) - - self.appearance().setBackgroundImage(nil, for: UIControlState(), style: UIBarButtonItemStyle.plain, barMetrics: UIBarMetrics.default) - self.appearance().setBackgroundImage(nil, for: UIControlState.highlighted, style: UIBarButtonItemStyle.plain, barMetrics: UIBarMetrics.default) - self.appearance().setBackgroundImage(nil, for: UIControlState.disabled, style: UIBarButtonItemStyle.plain, barMetrics: UIBarMetrics.default) - self.appearance().setBackgroundImage(nil, for: UIControlState.selected, style: UIBarButtonItemStyle.plain, barMetrics: UIBarMetrics.default) - self.appearance().setBackgroundImage(nil, for: UIControlState.application, style: UIBarButtonItemStyle.plain, barMetrics: UIBarMetrics.default) - self.appearance().setBackgroundImage(nil, for: UIControlState.reserved, style: UIBarButtonItemStyle.plain, barMetrics: UIBarMetrics.default) - self.appearance().setBackgroundVerticalPositionAdjustment(0, for: UIBarMetrics.default) + //Tint color + appearanceProxy.tintColor = nil - //Back Button - self.appearance().setBackButtonBackgroundImage(nil, for: UIControlState(), barMetrics: UIBarMetrics.default) - self.appearance().setBackButtonBackgroundImage(nil, for: UIControlState.highlighted, barMetrics: UIBarMetrics.default) - self.appearance().setBackButtonBackgroundImage(nil, for: UIControlState.disabled, barMetrics: UIBarMetrics.default) - self.appearance().setBackButtonBackgroundImage(nil, for: UIControlState.selected, barMetrics: UIBarMetrics.default) - self.appearance().setBackButtonBackgroundImage(nil, for: UIControlState.application, barMetrics: UIBarMetrics.default) - self.appearance().setBackButtonBackgroundImage(nil, for: UIControlState.reserved, barMetrics: UIBarMetrics.default) + for state in states { - self.appearance().setBackButtonTitlePositionAdjustment(UIOffset.zero, for: UIBarMetrics.default) - self.appearance().setBackButtonBackgroundVerticalPositionAdjustment(0, for: UIBarMetrics.default) + appearanceProxy.setTitleTextAttributes(nil, for: state) + appearanceProxy.setBackgroundImage(nil, for: state, barMetrics: .default) + appearanceProxy.setBackgroundImage(nil, for: state, style: .done, barMetrics: .default) + appearanceProxy.setBackgroundImage(nil, for: state, style: .plain, barMetrics: .default) + appearanceProxy.setBackButtonBackgroundImage(nil, for: state, barMetrics: .default) + } + + appearanceProxy.setTitlePositionAdjustment(UIOffset.zero, for: .default) + appearanceProxy.setBackgroundVerticalPositionAdjustment(0, for: .default) + appearanceProxy.setBackButtonTitlePositionAdjustment(UIOffset.zero, for: .default) + appearanceProxy.setBackButtonBackgroundVerticalPositionAdjustment(0, for: .default) } /** diff --git a/IQKeyboardManagerSwift/IQToolbar/IQToolbar.swift b/IQKeyboardManagerSwift/IQToolbar/IQToolbar.swift index d99adc51..5dd529c4 100644 --- a/IQKeyboardManagerSwift/IQToolbar/IQToolbar.swift +++ b/IQKeyboardManagerSwift/IQToolbar/IQToolbar.swift @@ -30,22 +30,22 @@ open class IQToolbar: UIToolbar , UIInputViewAudioFeedback { private static var _classInitialize: Void = classInitialize() private class func classInitialize() { - - self.appearance().barTintColor = nil - //Background image - self.appearance().setBackgroundImage(nil, forToolbarPosition: UIBarPosition.any, barMetrics: UIBarMetrics.default) - self.appearance().setBackgroundImage(nil, forToolbarPosition: UIBarPosition.bottom, barMetrics: UIBarMetrics.default) - self.appearance().setBackgroundImage(nil, forToolbarPosition: UIBarPosition.top, barMetrics: UIBarMetrics.default) - self.appearance().setBackgroundImage(nil, forToolbarPosition: UIBarPosition.topAttached, barMetrics: UIBarMetrics.default) + let appearanceProxy = self.appearance() - self.appearance().setShadowImage(nil, forToolbarPosition: UIBarPosition.any) - self.appearance().setShadowImage(nil, forToolbarPosition: UIBarPosition.bottom) - self.appearance().setShadowImage(nil, forToolbarPosition: UIBarPosition.top) - self.appearance().setShadowImage(nil, forToolbarPosition: UIBarPosition.topAttached) + appearanceProxy.tintColor = nil + appearanceProxy.barTintColor = nil + let positions : [UIBarPosition] = [.any,.bottom,.top,.topAttached]; + + for position in positions { + + appearanceProxy.setBackgroundImage(nil, forToolbarPosition: position, barMetrics: .default) + appearanceProxy.setShadowImage(nil, forToolbarPosition: .any) + } + //Background color - self.appearance().backgroundColor = nil + position.backgroundColor = nil } /**