瀏覽代碼

- Added couple of compile time validations for Xcode 11, iOS 13
- DisplayMode Default is renamed to default, I think this will not be a big deal to rename.
- Removed support for Xcode 8
- Swift Code Style improvements using swiftlint

iftekhar_qurashi 6 年之前
父節點
當前提交
012ef1dd3c
共有 27 個文件被更改,包括 544 次插入542 次删除
  1. 15 2
      .gitignore
  2. 2 2
      Demo/Objective_C_Demo/Resources/Info.plist
  3. 2 2
      Demo/Swift_Demo/Resources/Info.plist
  4. 2 2
      IQKeyboardManager.podspec.json
  5. 二進制
      IQKeyboardManager.xcodeproj/project.xcworkspace/xcuserdata/iemacbook01.xcuserdatad/UserInterfaceState.xcuserstate
  6. 0 3
      IQKeyboardManager/Constants/IQKeyboardManagerConstantsInternal.h
  7. 95 27
      IQKeyboardManager/IQKeyboardManager.m
  8. 2 18
      IQKeyboardManager/IQKeyboardReturnKeyHandler.m
  9. 0 2
      IQKeyboardManager/IQToolbar/IQTitleBarButtonItem.m
  10. 8 16
      IQKeyboardManager/IQToolbar/IQToolbar.m
  11. 0 26
      IQKeyboardManager/IQToolbar/IQUIView+IQKeyboardToolbar.m
  12. 4 3
      IQKeyboardManagerSwift.podspec.json
  13. 7 20
      IQKeyboardManagerSwift/Categories/IQNSArray+Sort.swift
  14. 2 2
      IQKeyboardManagerSwift/Categories/IQUIScrollView+Additions.swift
  15. 5 6
      IQKeyboardManagerSwift/Categories/IQUITextFieldView+Additions.swift
  16. 32 43
      IQKeyboardManagerSwift/Categories/IQUIView+Hierarchy.swift
  17. 2 4
      IQKeyboardManagerSwift/Categories/IQUIViewController+Additions.swift
  18. 7 10
      IQKeyboardManagerSwift/Constants/IQKeyboardManagerConstants.swift
  19. 0 3
      IQKeyboardManagerSwift/Constants/IQKeyboardManagerConstantsInternal.swift
  20. 198 151
      IQKeyboardManagerSwift/IQKeyboardManager.swift
  21. 27 35
      IQKeyboardManagerSwift/IQKeyboardReturnKeyHandler.swift
  22. 9 13
      IQKeyboardManagerSwift/IQTextView/IQTextView.swift
  23. 8 10
      IQKeyboardManagerSwift/IQToolbar/IQBarButtonItem.swift
  24. 1 2
      IQKeyboardManagerSwift/IQToolbar/IQInvocation.swift
  25. 20 21
      IQKeyboardManagerSwift/IQToolbar/IQTitleBarButtonItem.swift
  26. 45 58
      IQKeyboardManagerSwift/IQToolbar/IQToolbar.swift
  27. 51 61
      IQKeyboardManagerSwift/IQToolbar/IQUIView+IQKeyboardToolbar.swift

+ 15 - 2
.gitignore

@@ -1,5 +1,4 @@
 # Xcode
-#
 build/
 *.pbxuser
 !default.pbxuser
@@ -16,11 +15,25 @@ DerivedData
 *.hmap
 *.ipa
 *.xcuserstate
+
+#CocoaPods
 Pods/
 
 # MacOS X
-#
 .DS_Store
 *.DS_Store
 **/.DS_Store
 
+#Swift Package Manager
+.build
+/.previous-build
+*~
+\#*
+.\#*
+*.xcscmblueprint
+/default.profraw
+Utilities/Docker/*.tar.gz
+.swiftpm
+Packages/
+Package.pins
+Package.resolved

+ 2 - 2
Demo/Objective_C_Demo/Resources/Info.plist

@@ -17,11 +17,11 @@
 	<key>CFBundlePackageType</key>
 	<string>FMWK</string>
 	<key>CFBundleShortVersionString</key>
-	<string>6.3</string>
+	<string>6.4</string>
 	<key>CFBundleSignature</key>
 	<string>????</string>
 	<key>CFBundleVersion</key>
-	<string>6.3.0</string>
+	<string>6.4.0</string>
 	<key>LSRequiresIPhoneOS</key>
 	<true/>
 	<key>UILaunchStoryboardName</key>

+ 2 - 2
Demo/Swift_Demo/Resources/Info.plist

@@ -17,11 +17,11 @@
 	<key>CFBundlePackageType</key>
 	<string>FMWK</string>
 	<key>CFBundleShortVersionString</key>
-	<string>6.3</string>
+	<string>6.4</string>
 	<key>CFBundleSignature</key>
 	<string>????</string>
 	<key>CFBundleVersion</key>
-	<string>6.3.0</string>
+	<string>6.4.0</string>
 	<key>LSRequiresIPhoneOS</key>
 	<true/>
 	<key>UILaunchStoryboardName</key>

+ 2 - 2
IQKeyboardManager.podspec.json

@@ -1,9 +1,9 @@
 {
   "name": "IQKeyboardManager",
-  "version": "6.3.0",
+  "version": "6.4.0",
   "source": {
     "git": "https://github.com/hackiftekhar/IQKeyboardManager.git",
-    "tag": "v6.3.0"
+    "tag": "v6.4.0"
   },
   "summary": "Codeless drop-in universal library allows to prevent issues of keyboard sliding up and cover UITextField/UITextView.",
   "homepage": "https://github.com/hackiftekhar/IQKeyboardManager",

二進制
IQKeyboardManager.xcodeproj/project.xcworkspace/xcuserdata/iemacbook01.xcuserdatad/UserInterfaceState.xcuserstate


+ 0 - 3
IQKeyboardManager/Constants/IQKeyboardManagerConstantsInternal.h

@@ -25,7 +25,4 @@
 #define IQKeyboardManagerConstantsInternal_h
 
 
-#define IQ_IS_IOS10_OR_GREATER ([[NSProcessInfo processInfo] operatingSystemVersion].majorVersion >= 10)
-#define IQ_IS_IOS9_OR_GREATER ([[NSProcessInfo processInfo] operatingSystemVersion].majorVersion >= 9)
-
 #endif

+ 95 - 27
IQKeyboardManager/IQKeyboardManager.m

@@ -51,6 +51,10 @@
 #import <UIKit/UIWindow.h>
 #import <UIKit/NSLayoutConstraint.h>
 #import <UIKit/UIStackView.h>
+#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
+#import <UIKit/UIWindowScene.h>
+#import <UIKit/UIStatusBarManager.h>
+#endif
 
 NSInteger const kIQDoneButtonToolbarTag             =   -1002;
 NSInteger const kIQPreviousNextButtonToolbarTag     =   -1005;
@@ -650,8 +654,21 @@ NSInteger const kIQPreviousNextButtonToolbarTag     =   -1005;
             kbSize = intersectRect.size;
         }
     }
-    
-    CGFloat navigationBarAreaHeight = [[UIApplication sharedApplication] statusBarFrame].size.height + rootController.navigationController.navigationBar.frame.size.height;
+
+    CGFloat statusBarHeight = 0;
+#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
+    if (@available(iOS 13.0, *)) {
+        statusBarHeight = [self keyWindow].windowScene.statusBarManager.statusBarFrame.size.height;
+
+    } else
+#endif
+    {
+#if __IPHONE_OS_VERSION_MIN_REQUIRED < 130000
+        statusBarHeight = [[UIApplication sharedApplication] statusBarFrame].size.height;
+#endif
+    }
+
+    CGFloat navigationBarAreaHeight = statusBarHeight + rootController.navigationController.navigationBar.frame.size.height;
     CGFloat layoutAreaHeight = rootController.view.layoutMargins.top;
     
     CGFloat topLayoutGuide = MAX(navigationBarAreaHeight, layoutAreaHeight) + 5;
@@ -710,11 +727,8 @@ NSInteger const kIQPreviousNextButtonToolbarTag     =   -1005;
                 [self showLog:[NSString stringWithFormat:@"Restoring ScrollView contentOffset to : %@",NSStringFromCGPoint(_startingContentOffset)]];
                 
                 BOOL animatedContentOffset = NO;    //  (Bug ID: #1365, #1508, #1541)
-#ifdef __IPHONE_11_0
+
                 if (@available(iOS 9.0, *))
-#else
-                if (IQ_IS_IOS9_OR_GREATER)
-#endif
                 {
                     animatedContentOffset = ([textFieldView superviewOfClassType:[UIStackView class] belowView:strongLastScrollView] != nil);
                 }
@@ -755,11 +769,8 @@ NSInteger const kIQPreviousNextButtonToolbarTag     =   -1005;
                 [self showLog:[NSString stringWithFormat:@"Restoring ScrollView contentOffset to : %@",NSStringFromCGPoint(_startingContentOffset)]];
 
                 BOOL animatedContentOffset = NO;    //  (Bug ID: #1365, #1508, #1541)
-#ifdef __IPHONE_11_0
+
                 if (@available(iOS 9.0, *))
-#else
-                if (IQ_IS_IOS9_OR_GREATER)
-#endif
                 {
                     animatedContentOffset = ([textFieldView superviewOfClassType:[UIStackView class] belowView:strongLastScrollView] != nil);
                 }
@@ -774,8 +785,17 @@ NSInteger const kIQPreviousNextButtonToolbarTag     =   -1005;
             _lastScrollView = superScrollView;
             strongLastScrollView = _lastScrollView;
             _startingContentInsets = superScrollView.contentInset;
-            _startingScrollIndicatorInsets = superScrollView.scrollIndicatorInsets;
             _startingContentOffset = superScrollView.contentOffset;
+#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
+            if (@available(iOS 11.1, *)) {
+                _startingScrollIndicatorInsets = superScrollView.verticalScrollIndicatorInsets;
+            } else
+#endif
+            {
+#if __IPHONE_OS_VERSION_MIN_REQUIRED < 130000
+                _startingScrollIndicatorInsets = superScrollView.scrollIndicatorInsets;
+#endif
+            }
 
             [self showLog:[NSString stringWithFormat:@"Saving New contentInset: %@ and contentOffset : %@",NSStringFromUIEdgeInsets(_startingContentInsets),NSStringFromCGPoint(_startingContentOffset)]];
         }
@@ -788,7 +808,16 @@ NSInteger const kIQPreviousNextButtonToolbarTag     =   -1005;
         strongLastScrollView = _lastScrollView;
         _startingContentInsets = superScrollView.contentInset;
         _startingContentOffset = superScrollView.contentOffset;
-        _startingScrollIndicatorInsets = superScrollView.scrollIndicatorInsets;
+#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
+        if (@available(iOS 11.1, *)) {
+            _startingScrollIndicatorInsets = superScrollView.verticalScrollIndicatorInsets;
+        } else
+#endif
+        {
+#if __IPHONE_OS_VERSION_MIN_REQUIRED < 130000
+            _startingScrollIndicatorInsets = superScrollView.scrollIndicatorInsets;
+#endif
+        }
 
         [self showLog:[NSString stringWithFormat:@"Saving contentInset: %@ and contentOffset : %@",NSStringFromUIEdgeInsets(_startingContentInsets),NSStringFromCGPoint(_startingContentOffset)]];
     }
@@ -946,11 +975,8 @@ NSInteger const kIQPreviousNextButtonToolbarTag     =   -1005;
                         [strongSelf showLog:[NSString stringWithFormat:@"Remaining Move: %.2f",move]];
                         
                         BOOL animatedContentOffset = NO;    //  (Bug ID: #1365, #1508, #1541)
-#ifdef __IPHONE_11_0
+
                         if (@available(iOS 9.0, *))
-#else
-                        if (IQ_IS_IOS9_OR_GREATER)
-#endif
                         {
                             animatedContentOffset = ([textFieldView superviewOfClassType:[UIStackView class] belowView:superScrollView] != nil);
                         }
@@ -995,8 +1021,18 @@ NSInteger const kIQPreviousNextButtonToolbarTag     =   -1005;
                     [UIView animateWithDuration:_animationDuration delay:0 options:(_animationCurve|UIViewAnimationOptionBeginFromCurrentState) animations:^{
                         
                         strongLastScrollView.contentInset = movedInsets;
-                        
-                        UIEdgeInsets newInset = strongLastScrollView.scrollIndicatorInsets;
+                        UIEdgeInsets newInset;
+#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
+                        if (@available(iOS 11.1, *)) {
+                            newInset = strongLastScrollView.verticalScrollIndicatorInsets;
+                        } else
+#endif
+                        {
+#if __IPHONE_OS_VERSION_MIN_REQUIRED < 130000
+                            newInset = strongLastScrollView.scrollIndicatorInsets;
+#endif
+                        }
+
                         newInset.bottom = movedInsets.bottom;
                         strongLastScrollView.scrollIndicatorInsets = newInset;
                         
@@ -1029,7 +1065,17 @@ NSInteger const kIQPreviousNextButtonToolbarTag     =   -1005;
                 if (self.isTextViewContentInsetChanged == NO)
                 {
                     self.startingTextViewContentInsets = textView.contentInset;
-                    self.startingTextViewScrollIndicatorInsets = textView.scrollIndicatorInsets;
+                    
+#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
+                    if (@available(iOS 11.1, *)) {
+                        self.startingTextViewScrollIndicatorInsets = textView.verticalScrollIndicatorInsets;
+                    } else
+#endif
+                    {
+#if __IPHONE_OS_VERSION_MIN_REQUIRED < 130000
+                        self.startingTextViewScrollIndicatorInsets = textView.scrollIndicatorInsets;
+#endif
+                    }
                 }
 
                 UIEdgeInsets newContentInset = textView.contentInset;
@@ -1345,11 +1391,8 @@ NSInteger const kIQPreviousNextButtonToolbarTag     =   -1005;
                 [strongSelf showLog:[NSString stringWithFormat:@"Restoring ScrollView contentOffset to : %@",NSStringFromCGPoint(strongSelf.startingContentOffset)]];
 
                 BOOL animatedContentOffset = NO;    //  (Bug ID: #1365, #1508, #1541)
-#ifdef __IPHONE_11_0
+
                 if (@available(iOS 9.0, *))
-#else
-                if (IQ_IS_IOS9_OR_GREATER)
-#endif
                 {
                     animatedContentOffset = ([strongTextFieldView superviewOfClassType:[UIStackView class] belowView:strongLastScrollView] != nil);
                 }
@@ -1378,11 +1421,8 @@ NSInteger const kIQPreviousNextButtonToolbarTag     =   -1005;
                         [self showLog:[NSString stringWithFormat:@"Restoring contentOffset to : %@",NSStringFromCGPoint(newContentOffset)]];
 
                         BOOL animatedContentOffset = NO;    //  (Bug ID: #1365, #1508, #1541)
-#ifdef __IPHONE_11_0
+
                         if (@available(iOS 9.0, *))
-#else
-                        if (IQ_IS_IOS9_OR_GREATER)
-#endif
                         {
                             animatedContentOffset = ([strongSelf.textFieldView superviewOfClassType:[UIStackView class] belowView:superscrollView] != nil);
                         }
@@ -1590,6 +1630,28 @@ NSInteger const kIQPreviousNextButtonToolbarTag     =   -1005;
 /**  UIApplicationWillChangeStatusBarOrientationNotification. Need to set the textView to it's original position. If any frame changes made. (Bug ID: #92)*/
 - (void)willChangeStatusBarOrientation:(NSNotification*)aNotification
 {
+    UIInterfaceOrientation currentStatusBarOrientation = UIInterfaceOrientationUnknown;
+
+#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
+    if (@available(iOS 13.0, *)) {
+        currentStatusBarOrientation = [self keyWindow].windowScene.interfaceOrientation;
+    } else
+#endif
+    {
+#if __IPHONE_OS_VERSION_MIN_REQUIRED < 130000
+        currentStatusBarOrientation = UIApplication.sharedApplication.statusBarOrientation;
+#endif
+    }
+    
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+    UIInterfaceOrientation statusBarOrientation = [aNotification.userInfo[UIApplicationStatusBarOrientationUserInfoKey] integerValue];
+#pragma clang diagnostic pop
+    
+    if (statusBarOrientation != currentStatusBarOrientation) {
+        return;
+    }
+    
     CFTimeInterval startTime = CACurrentMediaTime();
     [self showLog:[NSString stringWithFormat:@"****** %@ started ******",NSStringFromSelector(_cmd)] indentation:1];
 
@@ -2260,7 +2322,10 @@ NSInteger const kIQPreviousNextButtonToolbarTag     =   -1005;
        didEndEditingNotificationName:UITextViewTextDidEndEditingNotification];
     
     //  Registering for orientation changes notification
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(willChangeStatusBarOrientation:) name:UIApplicationWillChangeStatusBarOrientationNotification object:[UIApplication sharedApplication]];
+#pragma clang diagnostic pop
 }
 
 -(void)unregisterAllNotifications
@@ -2282,7 +2347,10 @@ NSInteger const kIQPreviousNextButtonToolbarTag     =   -1005;
        didEndEditingNotificationName:UITextViewTextDidEndEditingNotification];
     
     //  Unregistering for orientation changes notification
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
     [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillChangeStatusBarOrientationNotification object:[UIApplication sharedApplication]];
+#pragma clang diagnostic pop
 }
 
 -(void)showLog:(NSString*)logString

+ 2 - 18
IQKeyboardManager/IQKeyboardReturnKeyHandler.m

@@ -345,14 +345,10 @@
         delegate = modal.textFieldDelegate;
     }
     
-#ifdef __IPHONE_11_0
     if (@available(iOS 10.0, *)) {
-#endif
         if ([delegate respondsToSelector:@selector(textFieldDidEndEditing:reason:)])
             [delegate textFieldDidEndEditing:textField reason:reason];
-#ifdef __IPHONE_11_0
     }
-#endif
 }
 
 - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
@@ -539,14 +535,10 @@
         delegate = modal.textViewDelegate;
     }
     
-#ifdef __IPHONE_11_0
     if (@available(iOS 10.0, *)) {
-#endif
         if ([delegate respondsToSelector:@selector(textView:shouldInteractWithURL:inRange:interaction:)])
             return [delegate textView:textView shouldInteractWithURL:URL inRange:characterRange interaction:interaction];
-#ifdef __IPHONE_11_0
     }
-#endif
 
     return YES;
 }
@@ -561,18 +553,15 @@
         delegate = modal.textViewDelegate;
     }
     
-#ifdef __IPHONE_11_0
     if (@available(iOS 10.0, *)) {
-#endif
     if ([delegate respondsToSelector:@selector(textView:shouldInteractWithTextAttachment:inRange:interaction:)])
         return [delegate textView:textView shouldInteractWithTextAttachment:textAttachment inRange:characterRange interaction:interaction];
-#ifdef __IPHONE_11_0
     }
-#endif
 
     return YES;
 }
 
+#if __IPHONE_OS_VERSION_MIN_REQUIRED < 100000
 - (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange
 {
     id<UITextViewDelegate> delegate = self.delegate;
@@ -583,11 +572,8 @@
         delegate = modal.textViewDelegate;
     }
     
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
     if ([delegate respondsToSelector:@selector(textView:shouldInteractWithURL:inRange:)])
         return [delegate textView:textView shouldInteractWithURL:URL inRange:characterRange];
-#pragma clang diagnostic pop
     else
         return YES;
 }
@@ -602,14 +588,12 @@
         delegate = modal.textViewDelegate;
     }
     
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
     if ([delegate respondsToSelector:@selector(textView:shouldInteractWithTextAttachment:inRange:)])
         return [delegate textView:textView shouldInteractWithTextAttachment:textAttachment inRange:characterRange];
-#pragma clang diagnostic pop
     else
         return YES;
 }
+#endif
 
 -(void)dealloc
 {

+ 0 - 2
IQKeyboardManager/IQToolbar/IQTitleBarButtonItem.m

@@ -56,7 +56,6 @@
         [self setTitleFont:[UIFont systemFontOfSize:13.0]];
         [_titleView addSubview:_titleButton];
         
-#ifdef __IPHONE_11_0
         if (@available(iOS 11.0, *))
         {
             CGFloat layoutDefaultLowPriority = UILayoutPriorityDefaultLow-1;
@@ -81,7 +80,6 @@
             [_titleView addConstraints:@[top,bottom,leading,trailing]];
         }
         else
-#endif
         {
             _titleView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
             _titleButton.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;

+ 8 - 16
IQKeyboardManager/IQToolbar/IQToolbar.m

@@ -140,18 +140,14 @@
     if (_fixedSpaceBarButton == nil)
     {
         _fixedSpaceBarButton = [[IQBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
-#ifdef __IPHONE_11_0
         if (@available(iOS 10.0, *))
-#else
-            if (IQ_IS_IOS10_OR_GREATER)
-#endif
-            {
-                [_fixedSpaceBarButton setWidth:6];
-            }
-            else
-            {
-                [_fixedSpaceBarButton setWidth:20];
-            }
+        {
+            [_fixedSpaceBarButton setWidth:6];
+        }
+        else
+        {
+            [_fixedSpaceBarButton setWidth:20];
+        }
     }
     
     return _fixedSpaceBarButton;
@@ -197,12 +193,8 @@
 {
     [super layoutSubviews];
 
-    //If running on Xcode9 (iOS11) only then we'll validate for iOS version, otherwise for older versions of Xcode (iOS10 and below) we'll just execute the tweak
-#ifdef __IPHONE_11_0
     if (@available(iOS 11.0, *)) {}
-    else
-#endif
-    {
+    else {
         CGRect leftRect = CGRectNull;
         CGRect rightRect = CGRectNull;
         

+ 0 - 26
IQKeyboardManager/IQToolbar/IQUIView+IQKeyboardToolbar.m

@@ -87,16 +87,12 @@
         keyboardPreviousiOS9Image = [UIImage imageNamed:@"IQButtonBarArrowLeft" inBundle:resourcesBundle compatibleWithTraitCollection:nil];;
         
         //Support for RTL languages like Arabic, Persia etc... (Bug ID: #448)
-#ifdef __IPHONE_11_0
         if (@available(iOS 9.0, *)) {
-#endif
             if ([UIImage instancesRespondToSelector:@selector(imageFlippedForRightToLeftLayoutDirection)])
             {
                 keyboardPreviousiOS9Image = [keyboardPreviousiOS9Image imageFlippedForRightToLeftLayoutDirection];
             }
-#ifdef __IPHONE_11_0
         }
-#endif
     }
     
     return keyboardPreviousiOS9Image;
@@ -121,16 +117,12 @@
         keyboardNextiOS9Image = [UIImage imageNamed:@"IQButtonBarArrowRight" inBundle:resourcesBundle compatibleWithTraitCollection:nil];
         
         //Support for RTL languages like Arabic, Persia etc... (Bug ID: #448)
-#ifdef __IPHONE_11_0
         if (@available(iOS 9.0, *)) {
-#endif
             if ([UIImage instancesRespondToSelector:@selector(imageFlippedForRightToLeftLayoutDirection)])
             {
                 keyboardNextiOS9Image = [keyboardNextiOS9Image imageFlippedForRightToLeftLayoutDirection];
             }
-#ifdef __IPHONE_11_0
         }
-#endif
     }
     
     return keyboardNextiOS9Image;
@@ -155,16 +147,12 @@
         keyboardPreviousiOS10Image = [UIImage imageNamed:@"IQButtonBarArrowUp" inBundle:resourcesBundle compatibleWithTraitCollection:nil];
         
         //Support for RTL languages like Arabic, Persia etc... (Bug ID: #448)
-#ifdef __IPHONE_11_0
         if (@available(iOS 9.0, *)) {
-#endif
             if ([UIImage instancesRespondToSelector:@selector(imageFlippedForRightToLeftLayoutDirection)])
             {
                 keyboardPreviousiOS10Image = [keyboardPreviousiOS10Image imageFlippedForRightToLeftLayoutDirection];
             }
-#ifdef __IPHONE_11_0
         }
-#endif
     }
     
     return keyboardPreviousiOS10Image;
@@ -189,16 +177,12 @@
         keyboardNextiOS10Image = [UIImage imageNamed:@"IQButtonBarArrowDown" inBundle:resourcesBundle compatibleWithTraitCollection:nil];
         
         //Support for RTL languages like Arabic, Persia etc... (Bug ID: #448)
-#ifdef __IPHONE_11_0
         if (@available(iOS 9.0, *)) {
-#endif
             if ([UIImage instancesRespondToSelector:@selector(imageFlippedForRightToLeftLayoutDirection)])
             {
                 keyboardNextiOS10Image = [keyboardNextiOS10Image imageFlippedForRightToLeftLayoutDirection];
             }
-#ifdef __IPHONE_11_0
         }
-#endif
     }
     
     return keyboardNextiOS10Image;
@@ -206,11 +190,7 @@
 
 +(UIImage*)keyboardPreviousImage
 {
-#ifdef __IPHONE_11_0
     if (@available(iOS 10.0, *))
-#else
-    if (IQ_IS_IOS10_OR_GREATER)
-#endif
     {
         return [UIImage keyboardPreviousiOS10Image];
     }
@@ -222,11 +202,7 @@
 
 +(UIImage*)keyboardNextImage
 {
-#ifdef __IPHONE_11_0
     if (@available(iOS 10.0, *))
-#else
-    if (IQ_IS_IOS10_OR_GREATER)
-#endif
     {
         return [UIImage keyboardNextiOS10Image];
     }
@@ -432,10 +408,8 @@
         
         //Title button
         toolbar.titleBarButton.title = titleText;
-#ifdef __IPHONE_11_0
         if (@available(iOS 11.0, *)) {}
         else
-#endif
         {
             toolbar.titleBarButton.customView.frame = CGRectZero;
         }

+ 4 - 3
IQKeyboardManagerSwift.podspec.json

@@ -1,9 +1,9 @@
 {
   "name": "IQKeyboardManagerSwift",
-  "version": "6.3.0",
+  "version": "6.4.0",
   "source": {
     "git": "https://github.com/hackiftekhar/IQKeyboardManager.git",
-    "tag": "v6.3.0"
+    "tag": "v6.4.0"
   },
   "summary": "Codeless drop-in universal library allows to prevent issues of keyboard sliding up and cover UITextField/UITextView.",
   "homepage": "https://github.com/hackiftekhar/IQKeyboardManager",
@@ -20,7 +20,8 @@
     "3.2",
     "4.0",
     "4.2",
-    "5.0"
+    "5.0",
+    "5.1"
   ],
   "source_files": "IQKeyboardManagerSwift/**/*.{swift}",
   "resources": "IQKeyboardManagerSwift/Resources/IQKeyboardManager.bundle",

+ 7 - 20
IQKeyboardManagerSwift/Categories/IQNSArray+Sort.swift

@@ -27,7 +27,7 @@ import UIKit
 /**
 UIView.subviews sorting category.
 */
-internal extension Array {
+internal extension Array where Element: UIView {
     
     ///--------------
     /// MARK: Sorting
@@ -38,12 +38,9 @@ internal extension Array {
     */
     func sortedArrayByTag() -> [Element] {
         
-        return sorted(by: { (obj1 : Element, obj2 : Element) -> Bool in
+        return sorted(by: { (obj1: Element, obj2: Element) -> Bool in
             
-            let view1 = obj1 as! UIView
-            let view2 = obj2 as! UIView
-            
-            return (view1.tag < view2.tag)
+            return (obj1.tag < obj2.tag)
         })
     }
     
@@ -52,22 +49,12 @@ internal extension Array {
     */
     func sortedArrayByPosition() -> [Element] {
         
-        return sorted(by: { (obj1 : Element, obj2 : Element) -> Bool in
-            
-            let view1 = obj1 as! UIView
-            let view2 = obj2 as! UIView
-            
-            let x1 = view1.frame.minX
-            let y1 = view1.frame.minY
-            let x2 = view2.frame.minX
-            let y2 = view2.frame.minY
-            
-            if y1 != y2 {
-                return y1 < y2
+        return sorted(by: { (obj1: Element, obj2: Element) -> Bool in
+            if obj1.frame.minY != obj2.frame.minY {
+                return obj1.frame.minY < obj2.frame.minY
             } else {
-                return x1 < x2
+                return obj1.frame.minX < obj2.frame.minX
             }
         })
     }
 }
-

+ 2 - 2
IQKeyboardManagerSwift/Categories/IQUIScrollView+Additions.swift

@@ -66,7 +66,7 @@ private var kIQShouldRestoreScrollViewContentOffset = "kIQShouldRestoreScrollVie
 
 internal extension UITableView {
     
-    func previousIndexPath(of indexPath:IndexPath) -> IndexPath? {
+    func previousIndexPath(of indexPath: IndexPath) -> IndexPath? {
         var previousRow = indexPath.row - 1
         var previousSection = indexPath.section
         
@@ -89,7 +89,7 @@ internal extension UITableView {
 
 internal extension UICollectionView {
     
-    func previousIndexPath(of indexPath:IndexPath) -> IndexPath? {
+    func previousIndexPath(of indexPath: IndexPath) -> IndexPath? {
         var previousRow = indexPath.row - 1
         var previousSection = indexPath.section
         

+ 5 - 6
IQKeyboardManagerSwift/Categories/IQUITextFieldView+Additions.swift

@@ -31,7 +31,7 @@ public let kIQUseDefaultKeyboardDistance = CGFloat.greatestFiniteMagnitude
 
 private var kIQKeyboardDistanceFromTextField = "kIQKeyboardDistanceFromTextField"
 //private var kIQKeyboardEnableMode = "kIQKeyboardEnableMode"
-private var kIQKeyboardShouldResignOnTouchOutsideMode = "kIQKeyboardShouldResignOnTouchOutsideMode"
+private var kIQShouldResignOnTouchOutsideMode = "kIQShouldResignOnTouchOutsideMode"
 private var kIQIgnoreSwitchingByNextPrevious = "kIQIgnoreSwitchingByNextPrevious"
 
 /**
@@ -82,7 +82,7 @@ UIView category for managing UITextField/UITextView
 //            if let savedMode = objc_getAssociatedObject(self, &kIQKeyboardEnableMode) as? IQEnableMode {
 //                return savedMode
 //            } else {
-//                return .Default
+//                return .default
 //            }
 //        }
 //        set(newValue) {
@@ -96,15 +96,14 @@ UIView category for managing UITextField/UITextView
     @objc var shouldResignOnTouchOutsideMode: IQEnableMode {
         get {
             
-            if let savedMode = objc_getAssociatedObject(self, &kIQKeyboardShouldResignOnTouchOutsideMode) as? IQEnableMode {
+            if let savedMode = objc_getAssociatedObject(self, &kIQShouldResignOnTouchOutsideMode) as? IQEnableMode {
                 return savedMode
             } else {
-                return .Default
+                return .default
             }
         }
         set(newValue) {
-            objc_setAssociatedObject(self, &kIQKeyboardShouldResignOnTouchOutsideMode, newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN_NONATOMIC)
+            objc_setAssociatedObject(self, &kIQShouldResignOnTouchOutsideMode, newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN_NONATOMIC)
         }
     }
 }
-

+ 32 - 43
IQKeyboardManagerSwift/Categories/IQUIView+Hierarchy.swift

@@ -21,7 +21,6 @@
 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 // THE SOFTWARE.
 
-
 import UIKit
 
 /**
@@ -36,7 +35,7 @@ UIView hierarchy category.
     /**
     Returns the UIViewController object that manages the receiver.
     */
-    @objc func viewContainingController()->UIViewController? {
+    @objc func viewContainingController() -> UIViewController? {
         
         var nextResponder: UIResponder? = self
         
@@ -55,7 +54,7 @@ UIView hierarchy category.
     /**
     Returns the topMost UIViewController object in hierarchy.
     */
-    @objc func topMostController()->UIViewController? {
+    @objc func topMostController() -> UIViewController? {
         
         var controllersHierarchy = [UIViewController]()
 
@@ -69,9 +68,9 @@ UIView hierarchy category.
                 controllersHierarchy.append(presented)
             }
             
-            var matchController :UIResponder? = viewContainingController()
+            var matchController: UIResponder? = viewContainingController()
 
-            while matchController != nil && controllersHierarchy.contains(matchController as! UIViewController) == false {
+            while let mController = matchController as? UIViewController, controllersHierarchy.contains(mController) == false {
                 
                 repeat {
                     matchController = matchController?.next
@@ -89,10 +88,10 @@ UIView hierarchy category.
     /**
      Returns the UIViewController object that is actually the parent of this object. Most of the time it's the viewController object which actually contains it, but result may be different if it's viewController is added as childViewController of another viewController.
      */
-    @objc func parentContainerViewController()->UIViewController? {
+    @objc func parentContainerViewController() -> UIViewController? {
         
         var matchController = viewContainingController()
-        var parentContainerViewController : UIViewController?
+        var parentContainerViewController: UIViewController?
 
         if var navController = matchController?.navigationController {
             
@@ -100,7 +99,7 @@ UIView hierarchy category.
                 navController = parentNav
             }
             
-            var parentController : UIViewController = navController
+            var parentController: UIViewController = navController
 
             while let parent = parentController.parent,
                 (parent.isKind(of: UINavigationController.self) == false &&
@@ -115,8 +114,7 @@ UIView hierarchy category.
             } else {
                 parentContainerViewController = parentController
             }
-        }
-        else if let tabController = matchController?.tabBarController {
+        } else if let tabController = matchController?.tabBarController {
             
             if let navController = tabController.selectedViewController as? UINavigationController {
                 parentContainerViewController = navController.topViewController
@@ -153,7 +151,7 @@ UIView hierarchy category.
      
      @param belowView view object in upper hierarchy where method should stop searching and return nil
 */
-    @objc func superviewOfClassType(_ classType:UIView.Type, belowView:UIView? = nil) -> UIView? {
+    @objc func superviewOfClassType(_ classType: UIView.Type, belowView: UIView? = nil) -> UIView? {
 
         var superView = superview
         
@@ -164,7 +162,7 @@ UIView hierarchy category.
                 //If it's UIScrollView, then validating for special cases
                 if unwrappedSuperView.isKind(of: UIScrollView.self) {
                     
-                    let classNameString = NSStringFromClass(type(of:unwrappedSuperView.self))
+                    let classNameString = NSStringFromClass(type(of: unwrappedSuperView.self))
 
                     //  If it's not UITableViewWrapperView class, this is internal class which is actually manage in UITableview. The speciality of this class is that it's superview is UITableView.
                     //  If it's not UITableViewCellScrollView class, this is internal class which is actually manage in UITableviewCell. The speciality of this class is that it's superview is UITableViewCell.
@@ -174,8 +172,7 @@ UIView hierarchy category.
                         classNameString.hasPrefix("_") == false {
                         return superView
                     }
-                }
-                else {
+                } else {
                     return superView
                 }
             } else if unwrappedSuperView == belowView {
@@ -191,7 +188,7 @@ UIView hierarchy category.
     /**
     Returns all siblings of the receiver which canBecomeFirstResponder.
     */
-    internal func responderSiblings()->[UIView] {
+    internal func responderSiblings() -> [UIView] {
 
         //Array of (UITextField/UITextView's).
         var tempTextFields = [UIView]()
@@ -201,7 +198,7 @@ UIView hierarchy category.
             
             for textField in siblings {
                 
-                if (textField == self || textField.ignoreSwitchingByNextPrevious == false) && textField._IQcanBecomeFirstResponder() == true {
+                if (textField == self || textField.ignoreSwitchingByNextPrevious == false) && textField.IQcanBecomeFirstResponder() == true {
                     tempTextFields.append(textField)
                 }
             }
@@ -213,14 +210,14 @@ UIView hierarchy category.
     /**
     Returns all deep subViews of the receiver which canBecomeFirstResponder.
     */
-    internal func deepResponderViews()->[UIView] {
+    internal func deepResponderViews() -> [UIView] {
         
         //Array of (UITextField/UITextView's).
         var textfields = [UIView]()
         
         for textField in subviews {
             
-            if (textField == self || textField.ignoreSwitchingByNextPrevious == false) && textField._IQcanBecomeFirstResponder() == true {
+            if (textField == self || textField.ignoreSwitchingByNextPrevious == false) && textField.IQcanBecomeFirstResponder() == true {
                 textfields.append(textField)
             }
 
@@ -234,40 +231,35 @@ UIView hierarchy category.
         }
         
         //subviews are returning in opposite order. Sorting according the frames 'y'.
-        return textfields.sorted(by: { (view1 : UIView, view2 : UIView) -> Bool in
+        return textfields.sorted(by: { (view1: UIView, view2: UIView) -> Bool in
             
             let frame1 = view1.convert(view1.bounds, to: self)
             let frame2 = view2.convert(view2.bounds, to: self)
 
-            let x1 = frame1.minX
-            let y1 = frame1.minY
-            let x2 = frame2.minX
-            let y2 = frame2.minY
-            
-            if y1 != y2 {
-                return y1 < y2
+            if frame1.minY != frame2.minY {
+                return frame1.minY < frame2.minY
             } else {
-                return x1 < x2
+                return frame1.minX < frame2.minX
             }
         })
     }
     
-    private func _IQcanBecomeFirstResponder() -> Bool {
+    private func IQcanBecomeFirstResponder() -> Bool {
         
-        var _IQcanBecomeFirstResponder = false
+        var IQcanBecomeFirstResponder = false
         
         //  Setting toolbar to keyboard.
         if let textField = self as? UITextField {
-            _IQcanBecomeFirstResponder = textField.isEnabled
+            IQcanBecomeFirstResponder = textField.isEnabled
         } else if let textView = self as? UITextView {
-            _IQcanBecomeFirstResponder = textView.isEditable
+            IQcanBecomeFirstResponder = textView.isEditable
         }
         
-        if _IQcanBecomeFirstResponder == true {
-            _IQcanBecomeFirstResponder = isUserInteractionEnabled == true && isHidden == false && alpha != 0.0 && isAlertViewTextField() == false && textFieldSearchBar() == nil
+        if IQcanBecomeFirstResponder == true {
+            IQcanBecomeFirstResponder = isUserInteractionEnabled == true && isHidden == false && alpha != 0.0 && isAlertViewTextField() == false && textFieldSearchBar() == nil
         }
 
-        return _IQcanBecomeFirstResponder
+        return IQcanBecomeFirstResponder
     }
 
     ///-------------------------
@@ -277,9 +269,9 @@ UIView hierarchy category.
     /**
      Returns searchBar if receiver object is UISearchBarTextField, otherwise return nil.
     */
-    internal func textFieldSearchBar()-> UISearchBar? {
+    internal func textFieldSearchBar() -> UISearchBar? {
         
-        var responder : UIResponder? = self.next
+        var responder: UIResponder? = self.next
         
         while let bar = responder {
             
@@ -298,9 +290,9 @@ UIView hierarchy category.
     /**
     Returns YES if the receiver object is UIAlertSheetTextField, otherwise return NO.
     */
-    internal func isAlertViewTextField()->Bool {
+    internal func isAlertViewTextField() -> Bool {
         
-        var alertViewController : UIResponder? = viewContainingController()
+        var alertViewController: UIResponder? = viewContainingController()
         
         var isAlertViewTextField = false
         
@@ -317,8 +309,8 @@ UIView hierarchy category.
         return isAlertViewTextField
     }
     
-    private func depth()->Int {
-        var depth : Int = 0
+    private func depth() -> Int {
+        var depth: Int = 0
         
         if let superView = superview {
             depth = superView.depth()+1
@@ -342,6 +334,3 @@ extension NSObject {
         return "<\(self) \(Unmanaged.passUnretained(self).toOpaque())>"
     }
 }
-
-
-

+ 2 - 4
IQKeyboardManagerSwift/Categories/IQUIViewController+Additions.swift

@@ -23,10 +23,8 @@
 
 import UIKit
 
-
 private var kIQLayoutGuideConstraint = "kIQLayoutGuideConstraint"
 
-
 @objc public extension UIViewController {
 
     /**
@@ -34,7 +32,7 @@ private var kIQLayoutGuideConstraint = "kIQLayoutGuideConstraint"
      
      @deprecated    Due to change in core-logic of handling distance between textField and keyboard distance, this layout contraint tweak is no longer needed and things will just work out of the box regardless of constraint pinned with safeArea/layoutGuide/superview
     */
-    @available(*,deprecated, message: "Due to change in core-logic of handling distance between textField and keyboard distance, this layout contraint tweak is no longer needed and things will just work out of the box regardless of constraint pinned with safeArea/layoutGuide/superview.")
+    @available(*, deprecated, message: "Due to change in core-logic of handling distance between textField and keyboard distance, this layout contraint tweak is no longer needed and things will just work out of the box regardless of constraint pinned with safeArea/layoutGuide/superview.")
     @IBOutlet @objc var IQLayoutGuideConstraint: NSLayoutConstraint? {
         get {
             
@@ -42,7 +40,7 @@ private var kIQLayoutGuideConstraint = "kIQLayoutGuideConstraint"
         }
 
         set(newValue) {
-            objc_setAssociatedObject(self, &kIQLayoutGuideConstraint, newValue,objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN_NONATOMIC)
+            objc_setAssociatedObject(self, &kIQLayoutGuideConstraint, newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN_NONATOMIC)
         }
     }
 }

+ 7 - 10
IQKeyboardManagerSwift/Constants/IQKeyboardManagerConstants.swift

@@ -21,7 +21,6 @@
 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 // THE SOFTWARE.
 
-
 import Foundation
 
 ///-----------------------------------
@@ -38,7 +37,7 @@ Creates Toolbar according to tag property of TextField's.
 `IQAutoToolbarByPosition`
 Creates Toolbar according to the y,x position of textField in it's superview coordinate.
 */
-@objc public enum IQAutoToolbarManageBehaviour : Int {
+@objc public enum IQAutoToolbarManageBehaviour: Int {
     case bySubviews
     case byTag
     case byPosition
@@ -54,8 +53,8 @@ Creates Toolbar according to the y,x position of textField in it's superview coo
  `IQPreviousNextDisplayModeAlwaysShow`
  Always show nextPrevious buttons, if there are more than 1 textField then both buttons will be visible but will be shown as disabled.
  */
-@objc public enum IQPreviousNextDisplayMode : Int {
-    case Default
+@objc public enum IQPreviousNextDisplayMode: Int {
+    case `default`
     case alwaysHide
     case alwaysShow
 }
@@ -70,21 +69,19 @@ Creates Toolbar according to the y,x position of textField in it's superview coo
  `IQEnableModeDisabled`
  setting is disabled.
  */
-@objc public enum IQEnableMode : Int {
-    case Default
+@objc public enum IQEnableMode: Int {
+    case `default`
     case enabled
     case disabled
 }
 
 /*
- 
  /---------------------------------------------------------------------------------------------------\
  \---------------------------------------------------------------------------------------------------/
  |                                   iOS Notification Mechanism                                    |
  /---------------------------------------------------------------------------------------------------\
  \---------------------------------------------------------------------------------------------------/
  
- 
  ------------------------------------------------------------
  When UITextField become first responder
  ------------------------------------------------------------
@@ -110,9 +107,9 @@ Creates Toolbar according to the y,x position of textField in it's superview coo
  ------------------------------------------------------------
  When switching focus from UITextView to another UITextView
  ------------------------------------------------------------
- - UITextViewTextDidEndEditingNotification : (UITextView1)
+ - UITextViewTextDidEndEditingNotification: (UITextView1)
  - UIKeyboardWillShowNotification
- - UITextViewTextDidBeginEditingNotification : (UITextView2)
+ - UITextViewTextDidBeginEditingNotification: (UITextView2)
  - UIKeyboardDidShowNotification
  
  ------------------------------------------------------------

+ 0 - 3
IQKeyboardManagerSwift/Constants/IQKeyboardManagerConstantsInternal.swift

@@ -21,7 +21,4 @@
 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 // THE SOFTWARE.
 
-
 import Foundation
-
-

文件差異過大導致無法顯示
+ 198 - 151
IQKeyboardManagerSwift/IQKeyboardManager.swift


+ 27 - 35
IQKeyboardManagerSwift/IQKeyboardReturnKeyHandler.swift

@@ -21,18 +21,17 @@
 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 // THE SOFTWARE.
 
-
 import Foundation
 import UIKit
 
-fileprivate class IQTextFieldViewInfoModal : NSObject {
+private class IQTextFieldViewInfoModal: NSObject {
 
     fileprivate weak var textFieldDelegate: UITextFieldDelegate?
     fileprivate weak var textViewDelegate: UITextViewDelegate?
     fileprivate weak var textFieldView: UIView?
     fileprivate var originalReturnKeyType = UIReturnKeyType.default
     
-    init(textFieldView : UIView?, textFieldDelegate : UITextFieldDelegate?, textViewDelegate : UITextViewDelegate?, originalReturnKeyType : UIReturnKeyType = .default) {
+    init(textFieldView: UIView?, textFieldDelegate: UITextFieldDelegate?, textViewDelegate: UITextViewDelegate?, originalReturnKeyType: UIReturnKeyType = .default) {
         self.textFieldView = textFieldView
         self.textFieldDelegate = textFieldDelegate
         self.textViewDelegate = textViewDelegate
@@ -43,9 +42,8 @@ fileprivate class IQTextFieldViewInfoModal : NSObject {
 /**
 Manages the return key to work like next/done in a view hierarchy.
 */
-public class IQKeyboardReturnKeyHandler: NSObject , UITextFieldDelegate, UITextViewDelegate {
-    
-    
+public class IQKeyboardReturnKeyHandler: NSObject, UITextFieldDelegate, UITextViewDelegate {
+
     ///---------------
     /// MARK: Settings
     ///---------------
@@ -58,7 +56,7 @@ public class IQKeyboardReturnKeyHandler: NSObject , UITextFieldDelegate, UITextV
     /**
     Set the last textfield return key type. Default is UIReturnKeyDefault.
     */
-    @objc public var lastTextFieldReturnKeyType : UIReturnKeyType = UIReturnKeyType.default {
+    @objc public var lastTextFieldReturnKeyType: UIReturnKeyType = UIReturnKeyType.default {
         
         didSet {
             
@@ -82,7 +80,7 @@ public class IQKeyboardReturnKeyHandler: NSObject , UITextFieldDelegate, UITextV
     /**
     Add all the textFields available in UIViewController's view.
     */
-    @objc public init(controller : UIViewController) {
+    @objc public init(controller: UIViewController) {
         super.init()
         
         addResponderFromView(controller.view)
@@ -107,7 +105,6 @@ public class IQKeyboardReturnKeyHandler: NSObject , UITextFieldDelegate, UITextV
         
         textFieldInfoCache.removeAll()
     }
-    
 
     ///------------------------
     /// MARK: Private variables
@@ -117,7 +114,7 @@ public class IQKeyboardReturnKeyHandler: NSObject , UITextFieldDelegate, UITextV
     ///------------------------
     /// MARK: Private Functions
     ///------------------------
-    private func textFieldViewCachedInfo(_ textField : UIView) -> IQTextFieldViewInfoModal? {
+    private func textFieldViewCachedInfo(_ textField: UIView) -> IQTextFieldViewInfoModal? {
         
         for modal in textFieldInfoCache {
             
@@ -132,9 +129,8 @@ public class IQKeyboardReturnKeyHandler: NSObject , UITextFieldDelegate, UITextV
         return nil
     }
 
-    private func updateReturnKeyTypeOnTextField(_ view : UIView)
-    {
-        var superConsideredView : UIView?
+    private func updateReturnKeyTypeOnTextField(_ view: UIView) {
+        var superConsideredView: UIView?
         
         //If find any consider responderView in it's upper hierarchy then will get deepResponderView. (Bug ID: #347)
         for disabledClass in IQKeyboardManager.shared.toolbarPreviousNextAllowedClasses {
@@ -170,15 +166,14 @@ public class IQKeyboardReturnKeyHandler: NSObject , UITextFieldDelegate, UITextV
             if let textField = view as? UITextField {
                 
                 //If it's the last textField in responder view, else next
-                textField.returnKeyType = (view == lastView)    ?   lastTextFieldReturnKeyType : UIReturnKeyType.next
+                textField.returnKeyType = (view == lastView)    ?   lastTextFieldReturnKeyType: UIReturnKeyType.next
             } else if let textView = view as? UITextView {
                 
                 //If it's the last textField in responder view, else next
-                textView.returnKeyType = (view == lastView)    ?   lastTextFieldReturnKeyType : UIReturnKeyType.next
+                textView.returnKeyType = (view == lastView)    ?   lastTextFieldReturnKeyType: UIReturnKeyType.next
             }
         }
     }
-    
 
     ///----------------------------------------------
     /// MARK: Registering/Unregistering textFieldView
@@ -189,7 +184,7 @@ public class IQKeyboardReturnKeyHandler: NSObject , UITextFieldDelegate, UITextV
     
     @param view UITextField/UITextView object to register.
     */
-    @objc public func addTextFieldView(_ view : UIView) {
+    @objc public func addTextFieldView(_ view: UIView) {
         
         let modal = IQTextFieldViewInfoModal(textFieldView: view, textFieldDelegate: nil, textViewDelegate: nil)
         
@@ -214,7 +209,7 @@ public class IQKeyboardReturnKeyHandler: NSObject , UITextFieldDelegate, UITextV
     
     @param view UITextField/UITextView object to unregister.
     */
-    @objc public func removeTextFieldView(_ view : UIView) {
+    @objc public func removeTextFieldView(_ view: UIView) {
         
         if let modal = textFieldViewCachedInfo(view) {
             
@@ -240,7 +235,7 @@ public class IQKeyboardReturnKeyHandler: NSObject , UITextFieldDelegate, UITextV
     
     @param view UIView object to register all it's responder subviews.
     */
-    @objc public func addResponderFromView(_ view : UIView) {
+    @objc public func addResponderFromView(_ view: UIView) {
         
         let textFields = view.deepResponderViews()
         
@@ -255,7 +250,7 @@ public class IQKeyboardReturnKeyHandler: NSObject , UITextFieldDelegate, UITextV
     
     @param view UIView object to unregister all it's responder subviews.
     */
-    @objc public func removeResponderFromView(_ view : UIView) {
+    @objc public func removeResponderFromView(_ view: UIView) {
         
         let textFields = view.deepResponderViews()
         
@@ -265,9 +260,9 @@ public class IQKeyboardReturnKeyHandler: NSObject , UITextFieldDelegate, UITextV
         }
     }
     
-    @discardableResult private func goToNextResponderOrResign(_ view : UIView) -> Bool {
+    @discardableResult private func goToNextResponderOrResign(_ view: UIView) -> Bool {
         
-        var superConsideredView : UIView?
+        var superConsideredView: UIView?
         
         //If find any consider responderView in it's upper hierarchy then will get deepResponderView. (Bug ID: #347)
         for disabledClass in IQKeyboardManager.shared.toolbarPreviousNextAllowedClasses {
@@ -316,7 +311,6 @@ public class IQKeyboardReturnKeyHandler: NSObject , UITextFieldDelegate, UITextV
             return true
         }
     }
-    
 
     ///---------------------------------------
     /// MARK: UITextField/UITextView delegates
@@ -353,7 +347,7 @@ public class IQKeyboardReturnKeyHandler: NSObject , UITextFieldDelegate, UITextV
     @objc public func textFieldDidBeginEditing(_ textField: UITextField) {
         updateReturnKeyTypeOnTextField(textField)
         
-        var aDelegate : UITextFieldDelegate? = delegate
+        var aDelegate: UITextFieldDelegate? = delegate
         
         if aDelegate == nil {
             
@@ -367,7 +361,7 @@ public class IQKeyboardReturnKeyHandler: NSObject , UITextFieldDelegate, UITextV
     
     @objc public func textFieldDidEndEditing(_ textField: UITextField) {
         
-        var aDelegate : UITextFieldDelegate? = delegate
+        var aDelegate: UITextFieldDelegate? = delegate
         
         if aDelegate == nil {
             
@@ -383,7 +377,7 @@ public class IQKeyboardReturnKeyHandler: NSObject , UITextFieldDelegate, UITextV
     @available(iOS 10.0, *)
     @objc public func textFieldDidEndEditing(_ textField: UITextField, reason: UITextField.DidEndEditingReason) {
         
-        var aDelegate : UITextFieldDelegate? = delegate
+        var aDelegate: UITextFieldDelegate? = delegate
         
         if aDelegate == nil {
             
@@ -398,7 +392,7 @@ public class IQKeyboardReturnKeyHandler: NSObject , UITextFieldDelegate, UITextV
     @available(iOS 10.0, *)
     @objc public func textFieldDidEndEditing(_ textField: UITextField, reason: UITextFieldDidEndEditingReason) {
 
-        var aDelegate : UITextFieldDelegate? = delegate
+        var aDelegate: UITextFieldDelegate? = delegate
     
         if aDelegate == nil {
     
@@ -437,8 +431,7 @@ public class IQKeyboardReturnKeyHandler: NSObject , UITextFieldDelegate, UITextV
 
         return true
     }
-    
-    
+
     @objc public func textFieldShouldReturn(_ textField: UITextField) -> Bool {
         
         var shouldReturn = true
@@ -459,8 +452,7 @@ public class IQKeyboardReturnKeyHandler: NSObject , UITextFieldDelegate, UITextV
             return goToNextResponderOrResign(textField)
         }
     }
-    
-    
+
     @objc public func textViewShouldBeginEditing(_ textView: UITextView) -> Bool {
         
         if delegate == nil {
@@ -492,7 +484,7 @@ public class IQKeyboardReturnKeyHandler: NSObject , UITextFieldDelegate, UITextV
     @objc public func textViewDidBeginEditing(_ textView: UITextView) {
         updateReturnKeyTypeOnTextField(textView)
         
-        var aDelegate : UITextViewDelegate? = delegate
+        var aDelegate: UITextViewDelegate? = delegate
         
         if aDelegate == nil {
             
@@ -506,7 +498,7 @@ public class IQKeyboardReturnKeyHandler: NSObject , UITextFieldDelegate, UITextV
     
     @objc public func textViewDidEndEditing(_ textView: UITextView) {
         
-        var aDelegate : UITextViewDelegate? = delegate
+        var aDelegate: UITextViewDelegate? = delegate
         
         if aDelegate == nil {
             
@@ -540,7 +532,7 @@ public class IQKeyboardReturnKeyHandler: NSObject , UITextFieldDelegate, UITextV
     
     @objc public func textViewDidChange(_ textView: UITextView) {
         
-        var aDelegate : UITextViewDelegate? = delegate
+        var aDelegate: UITextViewDelegate? = delegate
         
         if aDelegate == nil {
             
@@ -554,7 +546,7 @@ public class IQKeyboardReturnKeyHandler: NSObject , UITextFieldDelegate, UITextV
     
     @objc public func textViewDidChangeSelection(_ textView: UITextView) {
         
-        var aDelegate : UITextViewDelegate? = delegate
+        var aDelegate: UITextViewDelegate? = delegate
         
         if aDelegate == nil {
             

+ 9 - 13
IQKeyboardManagerSwift/IQTextView/IQTextView.swift

@@ -21,11 +21,10 @@
 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 // THE SOFTWARE.
 
-
 import UIKit
 
 /** @abstract UITextView with placeholder support   */
-open class IQTextView : UITextView {
+open class IQTextView: UITextView {
     
     @objc required public init?(coder aDecoder: NSCoder) {
         super.init(coder: aDecoder)
@@ -36,7 +35,7 @@ open class IQTextView : UITextView {
         let UITextViewTextDidChange = Notification.Name.UITextViewTextDidChange
         #endif
 
-        NotificationCenter.default.addObserver(self, selector: #selector(self.refreshPlaceholder), name:UITextViewTextDidChange, object: self)
+        NotificationCenter.default.addObserver(self, selector: #selector(self.refreshPlaceholder), name: UITextViewTextDidChange, object: self)
     }
     
     @objc override public init(frame: CGRect, textContainer: NSTextContainer?) {
@@ -68,11 +67,11 @@ open class IQTextView : UITextView {
         NotificationCenter.default.removeObserver(self)
     }
 
-    private var placeholderInsets : UIEdgeInsets {
+    private var placeholderInsets: UIEdgeInsets {
         return UIEdgeInsets(top: self.textContainerInset.top, left: self.textContainerInset.left + self.textContainer.lineFragmentPadding, bottom: self.textContainerInset.bottom, right: self.textContainerInset.right + self.textContainer.lineFragmentPadding)
     }
     
-    private var placeholderExpectedFrame : CGRect {
+    private var placeholderExpectedFrame: CGRect {
         let placeholderInsets = self.placeholderInsets
         let maxWidth = self.frame.width-placeholderInsets.left-placeholderInsets.right
         let expectedSize = placeholderLabel.sizeThatFits(CGSize(width: maxWidth, height: self.frame.height-placeholderInsets.top-placeholderInsets.bottom))
@@ -97,7 +96,7 @@ open class IQTextView : UITextView {
     }()
     
     /** @abstract To set textView's placeholder text color. */
-    @IBInspectable open var placeholderTextColor : UIColor? {
+    @IBInspectable open var placeholderTextColor: UIColor? {
         
         get {
             return placeholderLabel.textColor
@@ -109,7 +108,7 @@ open class IQTextView : UITextView {
     }
     
     /** @abstract To set textView's placeholder text. Default is nil.    */
-    @IBInspectable open var placeholder : String? {
+    @IBInspectable open var placeholder: String? {
         
         get {
             return placeholderLabel.text
@@ -162,7 +161,7 @@ open class IQTextView : UITextView {
         }
     }
     
-    @objc override open var font : UIFont? {
+    @objc override open var font: UIFont? {
         
         didSet {
             
@@ -174,14 +173,13 @@ open class IQTextView : UITextView {
         }
     }
     
-    @objc override open var textAlignment: NSTextAlignment
-        {
+    @objc override open var textAlignment: NSTextAlignment {
         didSet {
             placeholderLabel.textAlignment = textAlignment
         }
     }
     
-    @objc override open var delegate : UITextViewDelegate? {
+    @objc override open var delegate: UITextViewDelegate? {
         
         get {
             refreshPlaceholder()
@@ -205,5 +203,3 @@ open class IQTextView : UITextView {
         return newSize
     }
 }
-
-

+ 8 - 10
IQKeyboardManagerSwift/IQToolbar/IQBarButtonItem.swift

@@ -21,14 +21,13 @@
 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 // THE SOFTWARE.
 
-
 import UIKit
 import Foundation
 
 open class IQBarButtonItem: UIBarButtonItem {
 
     private static var _classInitialize: Void = classInitialize()
-    
+
     @objc public override init() {
         _ = IQBarButtonItem._classInitialize
           super.init()
@@ -39,18 +38,17 @@ open class IQBarButtonItem: UIBarButtonItem {
            super.init(coder: aDecoder)
        }
 
-   
     private class func classInitialize() {
 
         let  appearanceProxy = self.appearance()
 
         #if swift(>=4.2)
-        let states : [UIControl.State]
+        let states: [UIControl.State]
         #else
-        let states : [UIControlState]
+        let states: [UIControlState]
         #endif
 
-        states = [.normal,.highlighted,.disabled,.selected,.application,.reserved]
+        states = [.normal, .highlighted, .disabled, .selected, .application, .reserved]
 
         for state in states {
 
@@ -69,13 +67,13 @@ open class IQBarButtonItem: UIBarButtonItem {
         didSet {
 
             #if swift(>=4.2)
-            var textAttributes = [NSAttributedString.Key : Any]()
+            var textAttributes = [NSAttributedString.Key: Any]()
             let foregroundColorKey = NSAttributedString.Key.foregroundColor
             #elseif swift(>=4)
-            var textAttributes = [NSAttributedStringKey : Any]()
+            var textAttributes = [NSAttributedStringKey: Any]()
             let foregroundColorKey = NSAttributedStringKey.foregroundColor
             #else
-            var textAttributes = [String:Any]()
+            var textAttributes = [String: Any]()
             let foregroundColorKey = NSForegroundColorAttributeName
             #endif
 
@@ -127,7 +125,7 @@ open class IQBarButtonItem: UIBarButtonItem {
     /**
      Customized Invocation to be called when button is pressed. invocation is internally created using setTarget:action: method.
      */
-    @objc open var invocation : IQInvocation?
+    @objc open var invocation: IQInvocation?
     
     deinit {
         target = nil

+ 1 - 2
IQKeyboardManagerSwift/IQToolbar/IQInvocation.swift

@@ -21,10 +21,9 @@
 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 // THE SOFTWARE.
 
-
 import UIKit
 
-@objc public class IQInvocation : NSObject {
+@objc public class IQInvocation: NSObject {
     @objc public weak var target: AnyObject?
     @objc public var action: Selector
     

+ 20 - 21
IQKeyboardManagerSwift/IQToolbar/IQTitleBarButtonItem.swift

@@ -21,13 +21,12 @@
 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 // THE SOFTWARE.
 
-
 import Foundation
 import UIKit
 
 open class IQTitleBarButtonItem: IQBarButtonItem {
    
-    @objc open var titleFont : UIFont? {
+    @objc open var titleFont: UIFont? {
     
         didSet {
             if let unwrappedFont = titleFont {
@@ -47,14 +46,14 @@ open class IQTitleBarButtonItem: IQBarButtonItem {
     /**
      titleColor to be used for displaying button text when displaying title (disabled state).
      */
-    @objc open var titleColor : UIColor? {
+    @objc open var titleColor: UIColor? {
 
         didSet {
             
             if let color = titleColor {
-                titleButton?.setTitleColor(color, for:.disabled)
+                titleButton?.setTitleColor(color, for: .disabled)
             } else {
-                titleButton?.setTitleColor(UIColor.lightGray, for:.disabled)
+                titleButton?.setTitleColor(UIColor.lightGray, for: .disabled)
             }
         }
     }
@@ -62,14 +61,14 @@ open class IQTitleBarButtonItem: IQBarButtonItem {
     /**
      selectableTitleColor to be used for displaying button text when button is enabled.
      */
-    @objc open var selectableTitleColor : UIColor? {
+    @objc open var selectableTitleColor: UIColor? {
         
         didSet {
             
             if let color = selectableTitleColor {
-                titleButton?.setTitleColor(color, for:.normal)
+                titleButton?.setTitleColor(color, for: .normal)
             } else {
-                titleButton?.setTitleColor(UIColor.init(red: 0.0, green: 0.5, blue: 1.0, alpha: 1), for:.normal)
+                titleButton?.setTitleColor(UIColor.init(red: 0.0, green: 0.5, blue: 1.0, alpha: 1), for: .normal)
             }
         }
     }
@@ -77,7 +76,7 @@ open class IQTitleBarButtonItem: IQBarButtonItem {
     /**
      Customized Invocation to be called on title button action. titleInvocation is internally created using setTitleTarget:action: method.
      */
-    @objc override open var invocation : IQInvocation? {
+    @objc override open var invocation: IQInvocation? {
 
         didSet {
             
@@ -93,14 +92,14 @@ open class IQTitleBarButtonItem: IQBarButtonItem {
         }
     }
 
-    internal var titleButton : UIButton?
-    private var _titleView : UIView?
+    internal var titleButton: UIButton?
+    private var _titleView: UIView?
 
     override init() {
         super.init()
     }
     
-    @objc public convenience init(title : String?) {
+    @objc public convenience init(title: String?) {
 
         self.init(title: nil, style: .plain, target: nil, action: nil)
         
@@ -110,8 +109,8 @@ open class IQTitleBarButtonItem: IQBarButtonItem {
         titleButton = UIButton(type: .system)
         titleButton?.isEnabled = false
         titleButton?.titleLabel?.numberOfLines = 3
-        titleButton?.setTitleColor(UIColor.lightGray, for:.disabled)
-        titleButton?.setTitleColor(UIColor.init(red: 0.0, green: 0.5, blue: 1.0, alpha: 1), for:.normal)
+        titleButton?.setTitleColor(UIColor.lightGray, for: .disabled)
+        titleButton?.setTitleColor(UIColor.init(red: 0.0, green: 0.5, blue: 1.0, alpha: 1), for: .normal)
         titleButton?.backgroundColor = UIColor.clear
         titleButton?.titleLabel?.textAlignment = .center
         titleButton?.setTitle(title, for: .normal)
@@ -122,8 +121,8 @@ open class IQTitleBarButtonItem: IQBarButtonItem {
 #if swift(>=3.2)
         if #available(iOS 11, *) {
             
-            var layoutDefaultLowPriority : UILayoutPriority
-            var layoutDefaultHighPriority : UILayoutPriority
+            var layoutDefaultLowPriority: UILayoutPriority
+            var layoutDefaultHighPriority: UILayoutPriority
 
             #if swift(>=4.0)
                 let layoutPriorityLowValue = UILayoutPriority.defaultLow.rawValue-1
@@ -152,14 +151,14 @@ open class IQTitleBarButtonItem: IQBarButtonItem {
             let leading = NSLayoutConstraint.init(item: titleButton!, attribute: .leading, relatedBy: .equal, toItem: _titleView, attribute: .leading, multiplier: 1, constant: 0)
             let trailing = NSLayoutConstraint.init(item: titleButton!, attribute: .trailing, relatedBy: .equal, toItem: _titleView, attribute: .trailing, multiplier: 1, constant: 0)
             
-            _titleView?.addConstraints([top,bottom,leading,trailing])
+            _titleView?.addConstraints([top, bottom, leading, trailing])
         } else {
-            _titleView?.autoresizingMask = [.flexibleWidth,.flexibleHeight]
-            titleButton?.autoresizingMask = [.flexibleWidth,.flexibleHeight]
+            _titleView?.autoresizingMask = [.flexibleWidth, .flexibleHeight]
+            titleButton?.autoresizingMask = [.flexibleWidth, .flexibleHeight]
         }
 #else
-    _titleView?.autoresizingMask = [.flexibleWidth,.flexibleHeight]
-    titleButton?.autoresizingMask = [.flexibleWidth,.flexibleHeight]
+    _titleView?.autoresizingMask = [.flexibleWidth, .flexibleHeight]
+    titleButton?.autoresizingMask = [.flexibleWidth, .flexibleHeight]
 #endif
 
         customView = _titleView

+ 45 - 58
IQKeyboardManagerSwift/IQToolbar/IQToolbar.swift

@@ -21,11 +21,10 @@
 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 // THE SOFTWARE.
 
-
 import UIKit
 
 /** @abstract   IQToolbar for IQKeyboardManager.    */
-open class IQToolbar: UIToolbar , UIInputViewAudioFeedback {
+open class IQToolbar: UIToolbar, UIInputViewAudioFeedback {
 
     private static var _classInitialize: Void = classInitialize()
     
@@ -35,7 +34,7 @@ open class IQToolbar: UIToolbar , UIInputViewAudioFeedback {
 
         appearanceProxy.barTintColor = nil
         
-        let positions : [UIBarPosition] = [.any,.bottom,.top,.topAttached]
+        let positions: [UIBarPosition] = [.any, .bottom, .top, .topAttached]
 
         for position in positions {
 
@@ -51,7 +50,7 @@ open class IQToolbar: UIToolbar , UIInputViewAudioFeedback {
      Previous bar button of toolbar.
      */
     private var privatePreviousBarButton: IQBarButtonItem?
-    @objc open var previousBarButton : IQBarButtonItem {
+    @objc open var previousBarButton: IQBarButtonItem {
         get {
             if privatePreviousBarButton == nil {
                 privatePreviousBarButton = IQBarButtonItem(image: nil, style: .plain, target: nil, action: nil)
@@ -69,7 +68,7 @@ open class IQToolbar: UIToolbar , UIInputViewAudioFeedback {
      Next bar button of toolbar.
      */
     private var privateNextBarButton: IQBarButtonItem?
-    @objc open var nextBarButton : IQBarButtonItem {
+    @objc open var nextBarButton: IQBarButtonItem {
         get {
             if privateNextBarButton == nil {
                 privateNextBarButton = IQBarButtonItem(image: nil, style: .plain, target: nil, action: nil)
@@ -87,7 +86,7 @@ open class IQToolbar: UIToolbar , UIInputViewAudioFeedback {
      Title bar button of toolbar.
      */
     private var privateTitleBarButton: IQTitleBarButtonItem?
-    @objc open var titleBarButton : IQTitleBarButtonItem {
+    @objc open var titleBarButton: IQTitleBarButtonItem {
         get {
             if privateTitleBarButton == nil {
                 privateTitleBarButton = IQTitleBarButtonItem(title: nil)
@@ -105,7 +104,7 @@ open class IQToolbar: UIToolbar , UIInputViewAudioFeedback {
      Done bar button of toolbar.
      */
     private var privateDoneBarButton: IQBarButtonItem?
-    @objc open var doneBarButton : IQBarButtonItem {
+    @objc open var doneBarButton: IQBarButtonItem {
         get {
             if privateDoneBarButton == nil {
                 privateDoneBarButton = IQBarButtonItem(title: nil, style: .done, target: nil, action: nil)
@@ -123,7 +122,7 @@ open class IQToolbar: UIToolbar , UIInputViewAudioFeedback {
      Fixed space bar button of toolbar.
      */
     private var privateFixedSpaceBarButton: IQBarButtonItem?
-    @objc open var fixedSpaceBarButton : IQBarButtonItem {
+    @objc open var fixedSpaceBarButton: IQBarButtonItem {
         get {
             if privateFixedSpaceBarButton == nil {
                 privateFixedSpaceBarButton = IQBarButtonItem(barButtonSystemItem: .fixedSpace, target: nil, action: nil)
@@ -208,17 +207,11 @@ open class IQToolbar: UIToolbar , UIInputViewAudioFeedback {
             var rightRect = CGRect.null
             var isTitleBarButtonFound = false
             
-            let sortedSubviews = self.subviews.sorted(by: { (view1 : UIView, view2 : UIView) -> Bool in
-                
-                let x1 = view1.frame.minX
-                let y1 = view1.frame.minY
-                let x2 = view2.frame.minX
-                let y2 = view2.frame.minY
-                
-                if x1 != x2 {
-                    return x1 < x2
+            let sortedSubviews = self.subviews.sorted(by: { (view1: UIView, view2: UIView) -> Bool in
+                if view1.frame.minX != view2.frame.minX {
+                    return view1.frame.minX < view2.frame.minX
                 } else {
-                    return y1 < y2
+                    return view1.frame.minY < view2.frame.minY
                 }
             })
             
@@ -235,43 +228,43 @@ open class IQToolbar: UIToolbar , UIInputViewAudioFeedback {
                 }
             }
             
-            let titleMargin : CGFloat = 16
+            let titleMargin: CGFloat = 16
 
-            let maxWidth : CGFloat = self.frame.width - titleMargin*2 - (leftRect.isNull ? 0 : leftRect.maxX) - (rightRect.isNull ? 0 : self.frame.width - rightRect.minX)
+            let maxWidth: CGFloat = self.frame.width - titleMargin*2 - (leftRect.isNull ? 0 : leftRect.maxX) - (rightRect.isNull ? 0 : self.frame.width - rightRect.minX)
             let maxHeight = self.frame.height
             
             let sizeThatFits = customTitleView.sizeThatFits(CGSize(width: maxWidth, height: maxHeight))
             
-            var titleRect : CGRect
+            var titleRect: CGRect
             
             if sizeThatFits.width > 0 && sizeThatFits.height > 0 {
                 let width = min(sizeThatFits.width, maxWidth)
                 let height = min(sizeThatFits.height, maxHeight)
                 
-                var x : CGFloat
+                var xPosition: CGFloat
 
-                if (leftRect.isNull == false) {
-                    x = titleMargin + leftRect.maxX + ((maxWidth - width)/2)
+                if leftRect.isNull == false {
+                    xPosition = titleMargin + leftRect.maxX + ((maxWidth - width)/2)
                 } else {
-                    x = titleMargin
+                    xPosition = titleMargin
                 }
                 
-                let y = (maxHeight - height)/2
+                let yPosition = (maxHeight - height)/2
                 
-                titleRect = CGRect(x: x, y: y, width: width, height: height)
+                titleRect = CGRect(x: xPosition, y: yPosition, width: width, height: height)
             } else {
                 
-                var x : CGFloat
+                var xPosition: CGFloat
                 
-                if (leftRect.isNull == false) {
-                    x = titleMargin + leftRect.maxX
+                if leftRect.isNull == false {
+                    xPosition = titleMargin + leftRect.maxX
                 } else {
-                    x = titleMargin
+                    xPosition = titleMargin
                 }
 
-                let width : CGFloat = self.frame.width - titleMargin*2 - (leftRect.isNull ? 0 : leftRect.maxX) - (rightRect.isNull ? 0 : self.frame.width - rightRect.minX)
+                let width: CGFloat = self.frame.width - titleMargin*2 - (leftRect.isNull ? 0 : leftRect.maxX) - (rightRect.isNull ? 0 : self.frame.width - rightRect.minX)
                 
-                titleRect = CGRect(x: x, y: 0, width: width, height: maxHeight)
+                titleRect = CGRect(x: xPosition, y: 0, width: width, height: maxHeight)
             }
             
             customTitleView.frame = titleRect
@@ -283,17 +276,11 @@ open class IQToolbar: UIToolbar , UIInputViewAudioFeedback {
             var rightRect = CGRect.null
             var isTitleBarButtonFound = false
             
-            let sortedSubviews = self.subviews.sorted(by: { (view1 : UIView, view2 : UIView) -> Bool in
-                
-                let x1 = view1.frame.minX
-                let y1 = view1.frame.minY
-                let x2 = view2.frame.minX
-                let y2 = view2.frame.minY
-                
-                if x1 != x2 {
-                    return x1 < x2
+            let sortedSubviews = self.subviews.sorted(by: { (view1: UIView, view2: UIView) -> Bool in
+                if view1.frame.minX != view2.frame.minX {
+                    return view1.frame.minX < view2.frame.minX
                 } else {
-                    return y1 < y2
+                    return view1.frame.minY < view2.frame.minY
                 }
             })
             
@@ -310,42 +297,42 @@ open class IQToolbar: UIToolbar , UIInputViewAudioFeedback {
                 }
             }
             
-            let titleMargin : CGFloat = 16
-            let maxWidth : CGFloat = self.frame.width - titleMargin*2 - (leftRect.isNull ? 0 : leftRect.maxX) - (rightRect.isNull ? 0 : self.frame.width - rightRect.minX)
+            let titleMargin: CGFloat = 16
+            let maxWidth: CGFloat = self.frame.width - titleMargin*2 - (leftRect.isNull ? 0 : leftRect.maxX) - (rightRect.isNull ? 0 : self.frame.width - rightRect.minX)
             let maxHeight = self.frame.height
             
             let sizeThatFits = customTitleView.sizeThatFits(CGSize(width: maxWidth, height: maxHeight))
             
-            var titleRect : CGRect
+            var titleRect: CGRect
 
             if sizeThatFits.width > 0 && sizeThatFits.height > 0 {
                 let width = min(sizeThatFits.width, maxWidth)
                 let height = min(sizeThatFits.height, maxHeight)
                 
-                var x : CGFloat
+                var xPosition: CGFloat
                 
-                if (leftRect.isNull == false) {
-                    x = titleMargin + leftRect.maxX + ((maxWidth - width)/2)
+                if leftRect.isNull == false {
+                    xPosition = titleMargin + leftRect.maxX + ((maxWidth - width)/2)
                 } else {
-                    x = titleMargin
+                    xPosition = titleMargin
                 }
 
-                let y = (maxHeight - height)/2
+                let yPosition = (maxHeight - height)/2
                 
-                titleRect = CGRect(x: x, y: y, width: width, height: height)
+                titleRect = CGRect(x: xPosition, y: yPosition, width: width, height: height)
             } else {
                 
-                var x : CGFloat
+                var xPosition: CGFloat
                 
-                if (leftRect.isNull == false) {
-                    x = titleMargin + leftRect.maxX
+                if leftRect.isNull == false {
+                    xPosition = titleMargin + leftRect.maxX
                 } else {
-                    x = titleMargin
+                    xPosition = titleMargin
                 }
 
-                let width : CGFloat = self.frame.width - titleMargin*2 - (leftRect.isNull ? 0 : leftRect.maxX) - (rightRect.isNull ? 0 : self.frame.width - rightRect.minX)
+                let width: CGFloat = self.frame.width - titleMargin*2 - (leftRect.isNull ? 0 : leftRect.maxX) - (rightRect.isNull ? 0 : self.frame.width - rightRect.minX)
                 
-                titleRect = CGRect(x: x, y: 0, width: width, height: maxHeight)
+                titleRect = CGRect(x: xPosition, y: 0, width: width, height: maxHeight)
             }
             
             customTitleView.frame = titleRect

+ 51 - 61
IQKeyboardManagerSwift/IQToolbar/IQUIView+IQKeyboardToolbar.swift

@@ -21,7 +21,6 @@
 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 // THE SOFTWARE.
 
-
 import UIKit
 
 private var kIQShouldHideToolbarPlaceholder = "kIQShouldHideToolbarPlaceholder"
@@ -32,10 +31,10 @@ private var kIQKeyboardToolbar              = "kIQKeyboardToolbar"
 /**
  IQBarButtonItemConfiguration for creating toolbar with bar button items
  */
-@objc public class IQBarButtonItemConfiguration : NSObject {
+@objc public class IQBarButtonItemConfiguration: NSObject {
     
     #if swift(>=4.2)
-    @objc public init(barButtonSystemItem : UIBarButtonItem.SystemItem, action: Selector) {
+    @objc public init(barButtonSystemItem: UIBarButtonItem.SystemItem, action: Selector) {
         self.barButtonSystemItem = barButtonSystemItem
         self.image = nil
         self.title = nil
@@ -43,7 +42,7 @@ private var kIQKeyboardToolbar              = "kIQKeyboardToolbar"
         super.init()
     }
     #else
-    @objc public init(barButtonSystemItem : UIBarButtonSystemItem, action: Selector) {
+    @objc public init(barButtonSystemItem: UIBarButtonSystemItem, action: Selector) {
         self.barButtonSystemItem = barButtonSystemItem
         self.image = nil
         self.title = nil
@@ -52,7 +51,7 @@ private var kIQKeyboardToolbar              = "kIQKeyboardToolbar"
     }
     #endif
 
-    @objc public init(image : UIImage, action: Selector) {
+    @objc public init(image: UIImage, action: Selector) {
         self.barButtonSystemItem = nil
         self.image = image
         self.title = nil
@@ -60,7 +59,7 @@ private var kIQKeyboardToolbar              = "kIQKeyboardToolbar"
         super.init()
     }
     
-    @objc public init(title : String, action: Selector) {
+    @objc public init(title: String, action: Selector) {
         self.barButtonSystemItem = nil
         self.image = nil
         self.title = title
@@ -69,16 +68,16 @@ private var kIQKeyboardToolbar              = "kIQKeyboardToolbar"
     }
     
     #if swift(>=4.2)
-    public let barButtonSystemItem : UIBarButtonItem.SystemItem?    //System Item to be used to instantiate bar button.
+    public let barButtonSystemItem: UIBarButtonItem.SystemItem?    //System Item to be used to instantiate bar button.
     #else
-    public let barButtonSystemItem : UIBarButtonSystemItem?    //System Item to be used to instantiate bar button.
+    public let barButtonSystemItem: UIBarButtonSystemItem?    //System Item to be used to instantiate bar button.
     #endif
     
-    @objc public let image : UIImage?    //Image to show on bar button item if it's not a system item.
+    @objc public let image: UIImage?    //Image to show on bar button item if it's not a system item.
     
-    @objc public let title : String?     //Title to show on bar button item if it's not a system item.
+    @objc public let title: String?     //Title to show on bar button item if it's not a system item.
     
-    @objc public let action : Selector?  //action for bar button item. Usually 'doneAction:(IQBarButtonItem*)item'.
+    @objc public let action: Selector?  //action for bar button item. Usually 'doneAction:(IQBarButtonItem*)item'.
 }
 
 /**
@@ -89,7 +88,7 @@ private var kIQKeyboardToolbar              = "kIQKeyboardToolbar"
     @objc static func keyboardPreviousiOS9Image() -> UIImage? {
         
         struct Static {
-            static var keyboardPreviousiOS9Image : UIImage?
+            static var keyboardPreviousiOS9Image: UIImage?
         }
 
         if Static.keyboardPreviousiOS9Image == nil {
@@ -116,7 +115,7 @@ private var kIQKeyboardToolbar              = "kIQKeyboardToolbar"
     @objc static func keyboardNextiOS9Image() -> UIImage? {
         
         struct Static {
-            static var keyboardNextiOS9Image : UIImage?
+            static var keyboardNextiOS9Image: UIImage?
         }
         
         if Static.keyboardNextiOS9Image == nil {
@@ -143,7 +142,7 @@ private var kIQKeyboardToolbar              = "kIQKeyboardToolbar"
     @objc static func keyboardPreviousiOS10Image() -> UIImage? {
         
         struct Static {
-            static var keyboardPreviousiOS10Image : UIImage?
+            static var keyboardPreviousiOS10Image: UIImage?
         }
         
         if Static.keyboardPreviousiOS10Image == nil {
@@ -170,7 +169,7 @@ private var kIQKeyboardToolbar              = "kIQKeyboardToolbar"
     @objc static func keyboardNextiOS10Image() -> UIImage? {
         
         struct Static {
-            static var keyboardNextiOS10Image : UIImage?
+            static var keyboardNextiOS10Image: UIImage?
         }
         
         if Static.keyboardNextiOS10Image == nil {
@@ -228,8 +227,7 @@ UIView category methods to add IQToolbar on UIKeyboard.
     @objc var keyboardToolbar: IQToolbar {
         var toolbar = inputAccessoryView as? IQToolbar
         
-        if (toolbar == nil)
-        {
+        if toolbar == nil {
             toolbar = objc_getAssociatedObject(self, &kIQKeyboardToolbar) as? IQToolbar
         }
         
@@ -292,14 +290,11 @@ UIView category methods to add IQToolbar on UIKeyboard.
      */
     @objc var drawingToolbarPlaceholder: String? {
 
-        if (self.shouldHideToolbarPlaceholder)
-        {
+        if self.shouldHideToolbarPlaceholder {
             return nil
-        }
-        else if (self.toolbarPlaceholder?.isEmpty == false) {
+        } else if self.toolbarPlaceholder?.isEmpty == false {
             return self.toolbarPlaceholder
-        }
-        else if self.responds(to: #selector(getter: UITextField.placeholder)) {
+        } else if self.responds(to: #selector(getter: UITextField.placeholder)) {
             
             if let textField = self as? UITextField {
                 return textField.placeholder
@@ -308,8 +303,7 @@ UIView category methods to add IQToolbar on UIKeyboard.
             } else {
                 return nil
             }
-        }
-        else {
+        } else {
             return nil
         }
     }
@@ -322,7 +316,7 @@ UIView category methods to add IQToolbar on UIKeyboard.
         
         struct Static {
             
-            static let nilButton = IQBarButtonItem(barButtonSystemItem:.flexibleSpace, target: nil, action: nil)
+            static let nilButton = IQBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil)
         }
         
         Static.nilButton.isSystemItem = true
@@ -333,7 +327,7 @@ UIView category methods to add IQToolbar on UIKeyboard.
     /// MARK: Common
     ///-------------
 
-    @objc func addKeyboardToolbarWithTarget(target : AnyObject?, titleText : String?, rightBarButtonConfiguration:IQBarButtonItemConfiguration?, previousBarButtonConfiguration:IQBarButtonItemConfiguration? = nil, nextBarButtonConfiguration:IQBarButtonItemConfiguration? = nil) {
+    @objc func addKeyboardToolbarWithTarget(target: AnyObject?, titleText: String?, rightBarButtonConfiguration: IQBarButtonItemConfiguration?, previousBarButtonConfiguration: IQBarButtonItemConfiguration? = nil, nextBarButtonConfiguration: IQBarButtonItemConfiguration? = nil) {
         
         //If can't set InputAccessoryView. Then return
         if self.responds(to: #selector(setter: UITextField.inputAccessoryView)) {
@@ -341,7 +335,7 @@ UIView category methods to add IQToolbar on UIKeyboard.
             //  Creating a toolBar for phoneNumber keyboard
             let toolbar = self.keyboardToolbar
             
-            var items : [IQBarButtonItem] = []
+            var items: [IQBarButtonItem] = []
             
             if let prevConfig = previousBarButtonConfiguration {
 
@@ -415,8 +409,7 @@ UIView category methods to add IQToolbar on UIKeyboard.
                 toolbar.titleBarButton.title = titleText
                 
                 #if swift(>=3.2)
-                if #available(iOS 11, *) {}
-                else {
+                if #available(iOS 11, *) {} else {
                     toolbar.titleBarButton.customView?.frame = CGRect.zero
                 }
                 #else
@@ -488,38 +481,36 @@ UIView category methods to add IQToolbar on UIKeyboard.
     /// MARK: Right
     ///------------
 
-    @objc func addDoneOnKeyboardWithTarget(_ target : AnyObject?, action : Selector, shouldShowPlaceholder: Bool = false) {
+    @objc func addDoneOnKeyboardWithTarget(_ target: AnyObject?, action: Selector, shouldShowPlaceholder: Bool = false) {
         
-        addDoneOnKeyboardWithTarget(target, action: action, titleText: (shouldShowPlaceholder ? self.drawingToolbarPlaceholder : nil))
+        addDoneOnKeyboardWithTarget(target, action: action, titleText: (shouldShowPlaceholder ? self.drawingToolbarPlaceholder: nil))
     }
 
-    @objc func addDoneOnKeyboardWithTarget(_ target : AnyObject?, action : Selector, titleText: String?) {
+    @objc func addDoneOnKeyboardWithTarget(_ target: AnyObject?, action: Selector, titleText: String?) {
         
         let rightConfiguration = IQBarButtonItemConfiguration(barButtonSystemItem: .done, action: action)
         
         addKeyboardToolbarWithTarget(target: target, titleText: titleText, rightBarButtonConfiguration: rightConfiguration)
     }
-    
 
-    @objc func addRightButtonOnKeyboardWithImage(_ image : UIImage, target : AnyObject?, action : Selector, shouldShowPlaceholder: Bool = false) {
+    @objc func addRightButtonOnKeyboardWithImage(_ image: UIImage, target: AnyObject?, action: Selector, shouldShowPlaceholder: Bool = false) {
         
-        addRightButtonOnKeyboardWithImage(image, target: target, action: action, titleText: (shouldShowPlaceholder ? self.drawingToolbarPlaceholder : nil))
+        addRightButtonOnKeyboardWithImage(image, target: target, action: action, titleText: (shouldShowPlaceholder ? self.drawingToolbarPlaceholder: nil))
     }
     
-    @objc func addRightButtonOnKeyboardWithImage(_ image : UIImage, target : AnyObject?, action : Selector, titleText: String?) {
+    @objc func addRightButtonOnKeyboardWithImage(_ image: UIImage, target: AnyObject?, action: Selector, titleText: String?) {
         
         let rightConfiguration = IQBarButtonItemConfiguration(image: image, action: action)
         
         addKeyboardToolbarWithTarget(target: target, titleText: titleText, rightBarButtonConfiguration: rightConfiguration)
     }
-    
 
-    @objc func addRightButtonOnKeyboardWithText(_ text : String, target : AnyObject?, action : Selector, shouldShowPlaceholder: Bool = false) {
+    @objc func addRightButtonOnKeyboardWithText(_ text: String, target: AnyObject?, action: Selector, shouldShowPlaceholder: Bool = false) {
         
-        addRightButtonOnKeyboardWithText(text, target: target, action: action, titleText: (shouldShowPlaceholder ? self.drawingToolbarPlaceholder : nil))
+        addRightButtonOnKeyboardWithText(text, target: target, action: action, titleText: (shouldShowPlaceholder ? self.drawingToolbarPlaceholder: nil))
     }
     
-    @objc func addRightButtonOnKeyboardWithText(_ text : String, target : AnyObject?, action : Selector, titleText: String?) {
+    @objc func addRightButtonOnKeyboardWithText(_ text: String, target: AnyObject?, action: Selector, titleText: String?) {
         
         let rightConfiguration = IQBarButtonItemConfiguration(title: text, action: action)
         
@@ -530,30 +521,30 @@ UIView category methods to add IQToolbar on UIKeyboard.
     /// MARK: Right/Left
     ///-----------------
 
-    @objc func addCancelDoneOnKeyboardWithTarget(_ target : AnyObject?, cancelAction : Selector, doneAction : Selector, shouldShowPlaceholder: Bool = false) {
+    @objc func addCancelDoneOnKeyboardWithTarget(_ target: AnyObject?, cancelAction: Selector, doneAction: Selector, shouldShowPlaceholder: Bool = false) {
         
-        addCancelDoneOnKeyboardWithTarget(target, cancelAction: cancelAction, doneAction: doneAction, titleText: (shouldShowPlaceholder ? self.drawingToolbarPlaceholder : nil))
+        addCancelDoneOnKeyboardWithTarget(target, cancelAction: cancelAction, doneAction: doneAction, titleText: (shouldShowPlaceholder ? self.drawingToolbarPlaceholder: nil))
     }
 
-    @objc func addRightLeftOnKeyboardWithTarget(_ target : AnyObject?, leftButtonTitle : String, rightButtonTitle : String, leftButtonAction : Selector, rightButtonAction : Selector, shouldShowPlaceholder: Bool = false) {
+    @objc func addRightLeftOnKeyboardWithTarget(_ target: AnyObject?, leftButtonTitle: String, rightButtonTitle: String, leftButtonAction: Selector, rightButtonAction: Selector, shouldShowPlaceholder: Bool = false) {
         
-        addRightLeftOnKeyboardWithTarget(target, leftButtonTitle: leftButtonTitle, rightButtonTitle: rightButtonTitle, leftButtonAction: leftButtonAction, rightButtonAction: rightButtonAction, titleText: (shouldShowPlaceholder ? self.drawingToolbarPlaceholder : nil))
+        addRightLeftOnKeyboardWithTarget(target, leftButtonTitle: leftButtonTitle, rightButtonTitle: rightButtonTitle, leftButtonAction: leftButtonAction, rightButtonAction: rightButtonAction, titleText: (shouldShowPlaceholder ? self.drawingToolbarPlaceholder: nil))
     }
     
-    @objc func addRightLeftOnKeyboardWithTarget(_ target : AnyObject?, leftButtonImage : UIImage, rightButtonImage : UIImage, leftButtonAction : Selector, rightButtonAction : Selector, shouldShowPlaceholder: Bool = false) {
+    @objc func addRightLeftOnKeyboardWithTarget(_ target: AnyObject?, leftButtonImage: UIImage, rightButtonImage: UIImage, leftButtonAction: Selector, rightButtonAction: Selector, shouldShowPlaceholder: Bool = false) {
         
-        addRightLeftOnKeyboardWithTarget(target, leftButtonImage: leftButtonImage, rightButtonImage: rightButtonImage, leftButtonAction: leftButtonAction, rightButtonAction: rightButtonAction, titleText: (shouldShowPlaceholder ? self.drawingToolbarPlaceholder : nil))
+        addRightLeftOnKeyboardWithTarget(target, leftButtonImage: leftButtonImage, rightButtonImage: rightButtonImage, leftButtonAction: leftButtonAction, rightButtonAction: rightButtonAction, titleText: (shouldShowPlaceholder ? self.drawingToolbarPlaceholder: nil))
     }
     
-    @objc func addCancelDoneOnKeyboardWithTarget(_ target : AnyObject?, cancelAction : Selector, doneAction : Selector, titleText: String?) {
+    @objc func addCancelDoneOnKeyboardWithTarget(_ target: AnyObject?, cancelAction: Selector, doneAction: Selector, titleText: String?) {
         
         let leftConfiguration = IQBarButtonItemConfiguration(barButtonSystemItem: .cancel, action: cancelAction)
-        let rightConfiguration = IQBarButtonItemConfiguration(barButtonSystemItem: .done , action: doneAction)
+        let rightConfiguration = IQBarButtonItemConfiguration(barButtonSystemItem: .done, action: doneAction)
         
         addKeyboardToolbarWithTarget(target: target, titleText: titleText, rightBarButtonConfiguration: rightConfiguration, previousBarButtonConfiguration: leftConfiguration)
     }
     
-    @objc func addRightLeftOnKeyboardWithTarget(_ target : AnyObject?, leftButtonTitle : String, rightButtonTitle : String, leftButtonAction : Selector, rightButtonAction : Selector, titleText: String?) {
+    @objc func addRightLeftOnKeyboardWithTarget(_ target: AnyObject?, leftButtonTitle: String, rightButtonTitle: String, leftButtonAction: Selector, rightButtonAction: Selector, titleText: String?) {
         
         let leftConfiguration = IQBarButtonItemConfiguration(title: leftButtonTitle, action: leftButtonAction)
         let rightConfiguration = IQBarButtonItemConfiguration(title: rightButtonTitle, action: rightButtonAction)
@@ -561,7 +552,7 @@ UIView category methods to add IQToolbar on UIKeyboard.
         addKeyboardToolbarWithTarget(target: target, titleText: titleText, rightBarButtonConfiguration: rightConfiguration, previousBarButtonConfiguration: leftConfiguration)
     }
     
-    @objc func addRightLeftOnKeyboardWithTarget(_ target : AnyObject?, leftButtonImage : UIImage, rightButtonImage : UIImage, leftButtonAction : Selector, rightButtonAction : Selector, titleText: String?) {
+    @objc func addRightLeftOnKeyboardWithTarget(_ target: AnyObject?, leftButtonImage: UIImage, rightButtonImage: UIImage, leftButtonAction: Selector, rightButtonAction: Selector, titleText: String?) {
         
         let leftConfiguration = IQBarButtonItemConfiguration(image: leftButtonImage, action: leftButtonAction)
         let rightConfiguration = IQBarButtonItemConfiguration(image: rightButtonImage, action: rightButtonAction)
@@ -573,22 +564,22 @@ UIView category methods to add IQToolbar on UIKeyboard.
     /// MARK: Previous/Next/Right
     ///--------------------------
 
-    @objc func addPreviousNextDoneOnKeyboardWithTarget (_ target : AnyObject?, previousAction : Selector, nextAction : Selector, doneAction : Selector, shouldShowPlaceholder: Bool = false) {
+    @objc func addPreviousNextDoneOnKeyboardWithTarget (_ target: AnyObject?, previousAction: Selector, nextAction: Selector, doneAction: Selector, shouldShowPlaceholder: Bool = false) {
 
-        addPreviousNextDoneOnKeyboardWithTarget(target, previousAction: previousAction, nextAction: nextAction, doneAction: doneAction, titleText: (shouldShowPlaceholder ? self.drawingToolbarPlaceholder : nil))
+        addPreviousNextDoneOnKeyboardWithTarget(target, previousAction: previousAction, nextAction: nextAction, doneAction: doneAction, titleText: (shouldShowPlaceholder ? self.drawingToolbarPlaceholder: nil))
     }
 
-    @objc func addPreviousNextRightOnKeyboardWithTarget(_ target : AnyObject?, rightButtonImage : UIImage, previousAction : Selector, nextAction : Selector, rightButtonAction : Selector, shouldShowPlaceholder : Bool = false) {
+    @objc func addPreviousNextRightOnKeyboardWithTarget(_ target: AnyObject?, rightButtonImage: UIImage, previousAction: Selector, nextAction: Selector, rightButtonAction: Selector, shouldShowPlaceholder: Bool = false) {
         
-        addPreviousNextRightOnKeyboardWithTarget(target, rightButtonImage: rightButtonImage, previousAction: previousAction, nextAction: nextAction, rightButtonAction: rightButtonAction, titleText: (shouldShowPlaceholder ? self.drawingToolbarPlaceholder : nil))
+        addPreviousNextRightOnKeyboardWithTarget(target, rightButtonImage: rightButtonImage, previousAction: previousAction, nextAction: nextAction, rightButtonAction: rightButtonAction, titleText: (shouldShowPlaceholder ? self.drawingToolbarPlaceholder: nil))
     }
     
-    @objc func addPreviousNextRightOnKeyboardWithTarget(_ target : AnyObject?, rightButtonTitle : String, previousAction : Selector, nextAction : Selector, rightButtonAction : Selector, shouldShowPlaceholder : Bool = false) {
+    @objc func addPreviousNextRightOnKeyboardWithTarget(_ target: AnyObject?, rightButtonTitle: String, previousAction: Selector, nextAction: Selector, rightButtonAction: Selector, shouldShowPlaceholder: Bool = false) {
         
-        addPreviousNextRightOnKeyboardWithTarget(target, rightButtonTitle: rightButtonTitle, previousAction: previousAction, nextAction: nextAction, rightButtonAction: rightButtonAction, titleText: (shouldShowPlaceholder ? self.drawingToolbarPlaceholder : nil))
+        addPreviousNextRightOnKeyboardWithTarget(target, rightButtonTitle: rightButtonTitle, previousAction: previousAction, nextAction: nextAction, rightButtonAction: rightButtonAction, titleText: (shouldShowPlaceholder ? self.drawingToolbarPlaceholder: nil))
     }
     
-    @objc func addPreviousNextDoneOnKeyboardWithTarget (_ target : AnyObject?, previousAction : Selector, nextAction : Selector, doneAction : Selector,  titleText: String?) {
+    @objc func addPreviousNextDoneOnKeyboardWithTarget (_ target: AnyObject?, previousAction: Selector, nextAction: Selector, doneAction: Selector, titleText: String?) {
         
         let rightConfiguration = IQBarButtonItemConfiguration(barButtonSystemItem: .done, action: doneAction)
         let nextConfiguration = IQBarButtonItemConfiguration(image: UIImage.keyboardNextImage() ?? UIImage(), action: nextAction)
@@ -597,7 +588,7 @@ UIView category methods to add IQToolbar on UIKeyboard.
         addKeyboardToolbarWithTarget(target: target, titleText: titleText, rightBarButtonConfiguration: rightConfiguration, previousBarButtonConfiguration: prevConfiguration, nextBarButtonConfiguration: nextConfiguration)
     }
     
-    @objc func addPreviousNextRightOnKeyboardWithTarget(_ target : AnyObject?, rightButtonImage : UIImage, previousAction : Selector, nextAction : Selector, rightButtonAction : Selector, titleText : String?) {
+    @objc func addPreviousNextRightOnKeyboardWithTarget(_ target: AnyObject?, rightButtonImage: UIImage, previousAction: Selector, nextAction: Selector, rightButtonAction: Selector, titleText: String?) {
         
         let rightConfiguration = IQBarButtonItemConfiguration(image: rightButtonImage, action: rightButtonAction)
         let nextConfiguration = IQBarButtonItemConfiguration(image: UIImage.keyboardNextImage() ?? UIImage(), action: nextAction)
@@ -606,7 +597,7 @@ UIView category methods to add IQToolbar on UIKeyboard.
         addKeyboardToolbarWithTarget(target: target, titleText: titleText, rightBarButtonConfiguration: rightConfiguration, previousBarButtonConfiguration: prevConfiguration, nextBarButtonConfiguration: nextConfiguration)
     }
     
-    @objc func addPreviousNextRightOnKeyboardWithTarget(_ target : AnyObject?, rightButtonTitle : String, previousAction : Selector, nextAction : Selector, rightButtonAction : Selector, titleText : String?) {
+    @objc func addPreviousNextRightOnKeyboardWithTarget(_ target: AnyObject?, rightButtonTitle: String, previousAction: Selector, nextAction: Selector, rightButtonAction: Selector, titleText: String?) {
         
         let rightConfiguration = IQBarButtonItemConfiguration(title: rightButtonTitle, action: rightButtonAction)
         let nextConfiguration = IQBarButtonItemConfiguration(image: UIImage.keyboardNextImage() ?? UIImage(), action: nextAction)
@@ -615,4 +606,3 @@ UIView category methods to add IQToolbar on UIKeyboard.
         addKeyboardToolbarWithTarget(target: target, titleText: titleText, rightBarButtonConfiguration: rightConfiguration, previousBarButtonConfiguration: prevConfiguration, nextBarButtonConfiguration: nextConfiguration)
     }
 }
-

部分文件因文件數量過多而無法顯示