Skip to content

Commit c6bb989

Browse files
committed
- Adopted Light Move and Dark Mode in keyboard toolbar
1 parent 3f31c45 commit c6bb989

File tree

12 files changed

+43
-77
lines changed

12 files changed

+43
-77
lines changed

Demo.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,7 @@
11351135
PRODUCT_NAME = DemoSwift;
11361136
SWIFT_OBJC_BRIDGING_HEADER = "Demo/Swift_Demo/Resources/IQKeyboardManger-Swift-Bridging-Header.h";
11371137
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
1138-
SWIFT_VERSION = 4.2;
1138+
SWIFT_VERSION = 5.0;
11391139
TARGETED_DEVICE_FAMILY = "1,2";
11401140
};
11411141
name = Debug;
@@ -1169,7 +1169,7 @@
11691169
PRODUCT_BUNDLE_IDENTIFIER = com.iftekhar.IQKeyboardManagerSwift;
11701170
PRODUCT_NAME = DemoSwift;
11711171
SWIFT_OBJC_BRIDGING_HEADER = "Demo/Swift_Demo/Resources/IQKeyboardManger-Swift-Bridging-Header.h";
1172-
SWIFT_VERSION = 4.2;
1172+
SWIFT_VERSION = 5.0;
11731173
TARGETED_DEVICE_FAMILY = "1,2";
11741174
};
11751175
name = Release;

Demo.xcodeproj/xcshareddata/xcschemes/DemoSwift.xcscheme

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
2929
shouldUseLaunchSchemeArgsEnv = "YES">
30-
<Testables>
31-
</Testables>
3230
<MacroExpansion>
3331
<BuildableReference
3432
BuildableIdentifier = "primary"
@@ -38,8 +36,8 @@
3836
ReferencedContainer = "container:Demo.xcodeproj">
3937
</BuildableReference>
4038
</MacroExpansion>
41-
<AdditionalOptions>
42-
</AdditionalOptions>
39+
<Testables>
40+
</Testables>
4341
</TestAction>
4442
<LaunchAction
4543
buildConfiguration = "Debug"

IQKeyboardManager/IQKeyboardManager.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,17 +121,17 @@ extern NSInteger const kIQPreviousNextButtonToolbarTag;
121121
@property(nonatomic, assign) IQAutoToolbarManageBehaviour toolbarManageBehaviour;
122122

123123
/**
124-
If YES, then uses textField's tintColor property for IQToolbar, otherwise tint color is black. Default is NO.
124+
If YES, then uses textField's tintColor property for IQToolbar, otherwise tint color is nil. Default is NO.
125125
*/
126126
@property(nonatomic, assign) BOOL shouldToolbarUsesTextFieldTintColor;
127127

128128
/**
129-
This is used for toolbar.tintColor when textfield.keyboardAppearance is UIKeyboardAppearanceDefault. If shouldToolbarUsesTextFieldTintColor is YES then this property is ignored. Default is nil and uses black color.
129+
This is used for toolbar.tintColor when textfield.keyboardAppearance is UIKeyboardAppearanceDefault. If shouldToolbarUsesTextFieldTintColor is YES then this property is ignored. Default is nil.
130130
*/
131131
@property(nullable, nonatomic, strong) UIColor *toolbarTintColor;
132132

133133
/**
134-
This is used for toolbar.barTintColor. Default is nil and uses white color.
134+
This is used for toolbar.barTintColor. Default is nil.
135135
*/
136136
@property(nullable, nonatomic, strong) UIColor *toolbarBarTintColor;
137137

@@ -172,7 +172,7 @@ extern NSInteger const kIQPreviousNextButtonToolbarTag;
172172
@property(nullable, nonatomic, strong) UIColor *placeholderColor;
173173

174174
/**
175-
Placeholder Button Color when it's treated as button. Default is nil. Which means iOS Blue for light toolbar and Yellow for dark toolbar
175+
Placeholder Button Color when it's treated as button. Default is nil
176176
*/
177177
@property(nullable, nonatomic, strong) UIColor *placeholderButtonColor;
178178

IQKeyboardManager/IQKeyboardManager.m

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ -(void)adjustPosition
604604
// Getting KeyWindow object.
605605
UIWindow *keyWindow = [self keyWindow];
606606

607-
// We are unable to get textField object while keyboard showing on UIWebView's textField. (Bug ID: #11)
607+
// We are unable to get textField object while keyboard showing on WKWebView's textField. (Bug ID: #11)
608608
if (_hasPendingAdjustRequest == NO ||
609609
textFieldView == nil ||
610610
rootController == nil ||
@@ -1361,8 +1361,8 @@ - (void)keyboardWillHide:(NSNotification*)aNotification
13611361
CFTimeInterval startTime = CACurrentMediaTime();
13621362
[self showLog:[NSString stringWithFormat:@"****** %@ started ******",NSStringFromSelector(_cmd)] indentation:1];
13631363

1364-
//Commented due to #56. Added all the conditions below to handle UIWebView's textFields. (Bug ID: #56)
1365-
// We are unable to get textField object while keyboard showing on UIWebView's textField. (Bug ID: #11)
1364+
//Commented due to #56. Added all the conditions below to handle WKWebView's textFields. (Bug ID: #56)
1365+
// We are unable to get textField object while keyboard showing on WKWebView's textField. (Bug ID: #11)
13661366
// if (_textFieldView == nil) return;
13671367

13681368
//Restoring the contentOffset of the lastScrollView
@@ -2015,7 +2015,7 @@ -(void)addToolbarIfRequired
20152015
case UIKeyboardAppearanceDark:
20162016
{
20172017
toolbar.barStyle = UIBarStyleBlack;
2018-
[toolbar setTintColor:[UIColor whiteColor]];
2018+
[toolbar setTintColor:nil];
20192019
[toolbar setBarTintColor:nil];
20202020
}
20212021
break;
@@ -2035,7 +2035,7 @@ -(void)addToolbarIfRequired
20352035
}
20362036
else
20372037
{
2038-
toolbar.tintColor = [UIColor blackColor];
2038+
toolbar.tintColor = nil;
20392039
}
20402040
}
20412041
break;
@@ -2060,15 +2060,13 @@ -(void)addToolbarIfRequired
20602060
}
20612061

20622062
//Setting toolbar title color. // (Enhancement ID: #880)
2063-
if (_placeholderColor &&
2064-
[_placeholderColor isKindOfClass:[UIColor class]])
2063+
if (_placeholderColor)
20652064
{
20662065
[toolbar.titleBarButton setTitleColor:_placeholderColor];
20672066
}
20682067

20692068
//Setting toolbar button title color. // (Enhancement ID: #880)
2070-
if (_placeholderButtonColor &&
2071-
[_placeholderButtonColor isKindOfClass:[UIColor class]])
2069+
if (_placeholderButtonColor)
20722070
{
20732071
[toolbar.titleBarButton setSelectableTitleColor:_placeholderButtonColor];
20742072
}

IQKeyboardManager/IQTextView/IQTextView.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ -(UILabel*)placeholderLabel
165165
_placeholderLabel.font = self.font;
166166
_placeholderLabel.textAlignment = self.textAlignment;
167167
_placeholderLabel.backgroundColor = [UIColor clearColor];
168-
_placeholderLabel.textColor = [UIColor colorWithWhite:0.7 alpha:1.0];
168+
_placeholderLabel.textColor = [UIColor lightTextColor];
169+
// _placeholderLabel.textColor = [UIColor systemGrayColor]; //iOS 13
169170
_placeholderLabel.alpha = 0;
170171
[self addSubview:_placeholderLabel];
171172
}

IQKeyboardManager/IQToolbar/IQTitleBarButtonItem.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ -(nonnull instancetype)initWithTitle:(nullable NSString *)title
4949
_titleButton.enabled = NO;
5050
_titleButton.titleLabel.numberOfLines = 3;
5151
[_titleButton setTitleColor:[UIColor colorWithRed:0.0 green:0.5 blue:1.0 alpha:1.0] forState:UIControlStateNormal];
52+
// [_titleButton setTitleColor:[UIColor systemBlueColor] forState:UIControlStateNormal]; //iOS 13
5253
[_titleButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateDisabled];
5354
[_titleButton setBackgroundColor:[UIColor clearColor]];
5455
[_titleButton.titleLabel setTextAlignment:NSTextAlignmentCenter];
@@ -120,6 +121,7 @@ -(void)setSelectableTitleColor:(UIColor*)selectableTitleColor
120121
{
121122
_selectableTitleColor = selectableTitleColor;
122123
[_titleButton setTitleColor:_selectableTitleColor?:[UIColor colorWithRed:0.0 green:0.5 blue:1.0 alpha:1.0] forState:UIControlStateNormal];
124+
// [_titleButton setTitleColor:_selectableTitleColor?:[UIColor systemBlueColor] forState:UIControlStateNormal]; //iOS 13
123125
}
124126

125127
-(void)setInvocation:(NSInvocation *)invocation

IQKeyboardManager/IQToolbar/IQToolbar.m

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,6 @@
2929
#import <UIKit/UIAccessibility.h>
3030
#import <UIKit/UIViewController.h>
3131

32-
@interface IQTitleBarButtonItem (PrivateAccessor)
33-
34-
@property(nonnull, nonatomic, strong) UIButton *titleButton;
35-
36-
@end
37-
3832
@implementation IQToolbar
3933
@synthesize previousBarButton = _previousBarButton;
4034
@synthesize nextBarButton = _nextBarButton;
@@ -162,23 +156,6 @@ -(CGSize)sizeThatFits:(CGSize)size
162156
return sizeThatFit;
163157
}
164158

165-
-(void)setBarStyle:(UIBarStyle)barStyle
166-
{
167-
[super setBarStyle:barStyle];
168-
169-
if (self.titleBarButton.selectableTitleColor == nil)
170-
{
171-
if (barStyle == UIBarStyleDefault)
172-
{
173-
[self.titleBarButton.titleButton setTitleColor:[UIColor colorWithRed:0.0 green:0.5 blue:1.0 alpha:1.0] forState:UIControlStateNormal];
174-
}
175-
else
176-
{
177-
[self.titleBarButton.titleButton setTitleColor:[UIColor yellowColor] forState:UIControlStateNormal];
178-
}
179-
}
180-
}
181-
182159
-(void)setTintColor:(UIColor *)tintColor
183160
{
184161
[super setTintColor:tintColor];

IQKeyboardManagerSwift/IQKeyboardManager.swift

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ Codeless drop-in universal library allows to prevent issues of keyboard sliding
256256
@objc public var toolbarManageBehaviour = IQAutoToolbarManageBehaviour.bySubviews
257257

258258
/**
259-
If YES, then uses textField's tintColor property for IQToolbar, otherwise tint color is black. Default is NO.
259+
If YES, then uses textField's tintColor property for IQToolbar, otherwise tint color is default. Default is NO.
260260
*/
261261
@objc public var shouldToolbarUsesTextFieldTintColor = false
262262

@@ -266,7 +266,7 @@ Codeless drop-in universal library allows to prevent issues of keyboard sliding
266266
@objc public var toolbarTintColor: UIColor?
267267

268268
/**
269-
This is used for toolbar.barTintColor. Default is nil and uses white color.
269+
This is used for toolbar.barTintColor. Default is nil.
270270
*/
271271
@objc public var toolbarBarTintColor: UIColor?
272272

@@ -307,7 +307,7 @@ Codeless drop-in universal library allows to prevent issues of keyboard sliding
307307
@objc public var placeholderColor: UIColor?
308308

309309
/**
310-
Placeholder Button Color when it's treated as button. Default is nil. Which means iOS Blue for light toolbar and Yellow for dark toolbar
310+
Placeholder Button Color when it's treated as button. Default is nil.
311311
*/
312312
@objc public var placeholderButtonColor: UIColor?
313313

@@ -927,7 +927,7 @@ Codeless drop-in universal library allows to prevent issues of keyboard sliding
927927
/* Adjusting RootViewController's frame according to interface orientation. */
928928
private func adjustPosition() {
929929

930-
// We are unable to get textField object while keyboard showing on UIWebView's textField. (Bug ID: #11)
930+
// We are unable to get textField object while keyboard showing on WKWebView's textField. (Bug ID: #11)
931931
if _privateHasPendingAdjustRequest == true,
932932
let textFieldView = _textFieldView,
933933
let rootController = textFieldView.parentContainerViewController(),
@@ -1615,8 +1615,8 @@ Codeless drop-in universal library allows to prevent issues of keyboard sliding
16151615
let startTime = CACurrentMediaTime()
16161616
showLog("****** \(#function) started ******", indentation: 1)
16171617

1618-
//Commented due to #56. Added all the conditions below to handle UIWebView's textFields. (Bug ID: #56)
1619-
// We are unable to get textField object while keyboard showing on UIWebView's textField. (Bug ID: #11)
1618+
//Commented due to #56. Added all the conditions below to handle WKWebView's textFields. (Bug ID: #56)
1619+
// We are unable to get textField object while keyboard showing on WKWebView's textField. (Bug ID: #11)
16201620
// if (_textFieldView == nil) return
16211621

16221622
//Restoring the contentOffset of the lastScrollView
@@ -2014,11 +2014,11 @@ Codeless drop-in universal library allows to prevent issues of keyboard sliding
20142014
switch textField.keyboardAppearance {
20152015

20162016
case .dark:
2017-
toolbar.barStyle = UIBarStyle.black
2018-
toolbar.tintColor = UIColor.white
2017+
toolbar.barStyle = .black
2018+
toolbar.tintColor = nil
20192019
toolbar.barTintColor = nil
20202020
default:
2021-
toolbar.barStyle = UIBarStyle.default
2021+
toolbar.barStyle = .default
20222022
toolbar.barTintColor = toolbarBarTintColor
20232023

20242024
//Setting toolbar tintColor // (Enhancement ID: #30)
@@ -2027,7 +2027,7 @@ Codeless drop-in universal library allows to prevent issues of keyboard sliding
20272027
} else if let tintColor = toolbarTintColor {
20282028
toolbar.tintColor = tintColor
20292029
} else {
2030-
toolbar.tintColor = UIColor.black
2030+
toolbar.tintColor = nil
20312031
}
20322032
}
20332033
} else if let textView = textField as? UITextView {
@@ -2036,19 +2036,19 @@ Codeless drop-in universal library allows to prevent issues of keyboard sliding
20362036
switch textView.keyboardAppearance {
20372037

20382038
case .dark:
2039-
toolbar.barStyle = UIBarStyle.black
2040-
toolbar.tintColor = UIColor.white
2039+
toolbar.barStyle = .black
2040+
toolbar.tintColor = nil
20412041
toolbar.barTintColor = nil
20422042
default:
2043-
toolbar.barStyle = UIBarStyle.default
2043+
toolbar.barStyle = .default
20442044
toolbar.barTintColor = toolbarBarTintColor
20452045

20462046
if shouldToolbarUsesTextFieldTintColor {
20472047
toolbar.tintColor = textView.tintColor
20482048
} else if let tintColor = toolbarTintColor {
20492049
toolbar.tintColor = tintColor
20502050
} else {
2051-
toolbar.tintColor = UIColor.black
2051+
toolbar.tintColor = nil
20522052
}
20532053
}
20542054
}

IQKeyboardManagerSwift/IQTextView/IQTextView.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ open class IQTextView: UITextView {
8888
label.font = self.font
8989
label.textAlignment = self.textAlignment
9090
label.backgroundColor = UIColor.clear
91-
label.textColor = UIColor(white: 0.7, alpha: 1.0)
91+
label.textColor = UIColor.lightText
92+
// label.textColor = UIColor.systemGray //For iOS13
9293
label.alpha = 0
9394
self.addSubview(label)
9495

IQKeyboardManagerSwift/IQToolbar/IQTitleBarButtonItem.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ open class IQTitleBarButtonItem: IQBarButtonItem {
6868
if let color = selectableTitleColor {
6969
titleButton?.setTitleColor(color, for: .normal)
7070
} else {
71-
titleButton?.setTitleColor(UIColor.init(red: 0.0, green: 0.5, blue: 1.0, alpha: 1), for: .normal)
71+
titleButton?.setTitleColor(UIColor(red: 0.0, green: 0.5, blue: 1.0, alpha: 1), for: .normal)
72+
// titleButton?.setTitleColor(UIColor.systemBlue, for: .normal) //iO S13
7273
}
7374
}
7475
}
@@ -110,7 +111,8 @@ open class IQTitleBarButtonItem: IQBarButtonItem {
110111
titleButton?.isEnabled = false
111112
titleButton?.titleLabel?.numberOfLines = 3
112113
titleButton?.setTitleColor(UIColor.lightGray, for: .disabled)
113-
titleButton?.setTitleColor(UIColor.init(red: 0.0, green: 0.5, blue: 1.0, alpha: 1), for: .normal)
114+
titleButton?.setTitleColor(UIColor(red: 0.0, green: 0.5, blue: 1.0, alpha: 1), for: .normal)
115+
// titleButton?.setTitleColor(UIColor.systemBlue, for: .normal) //iOS 13
114116
titleButton?.backgroundColor = UIColor.clear
115117
titleButton?.titleLabel?.textAlignment = .center
116118
titleButton?.setTitle(title, for: .normal)

0 commit comments

Comments
 (0)