热点连接流程修改
This commit is contained in:
@@ -37,11 +37,11 @@
|
||||
/**
|
||||
Returns the array by sorting the UIView's by their tag property.
|
||||
*/
|
||||
@property (nonatomic, readonly, copy) NSArray<__kindof UIView*> * _Nonnull sortedArrayByTag;
|
||||
@property (nonnull, nonatomic, readonly, copy) NSArray<__kindof UIView*> * sortedArrayByTag;
|
||||
|
||||
/**
|
||||
Returns the array by sorting the UIView's by their tag property.
|
||||
*/
|
||||
@property (nonatomic, readonly, copy) NSArray<__kindof UIView*> * _Nonnull sortedArrayByPosition;
|
||||
@property (nonnull, nonatomic, readonly, copy) NSArray<__kindof UIView*> * sortedArrayByPosition;
|
||||
|
||||
@end
|
||||
|
||||
+16
-1
@@ -21,7 +21,8 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#import <UIKit/UIScrollView.h>
|
||||
#import <UIKit/UITableView.h>
|
||||
#import <UIKit/UICollectionView.h>
|
||||
|
||||
|
||||
@interface UIScrollView (Additions)
|
||||
@@ -37,4 +38,18 @@
|
||||
@property(nonatomic, assign) BOOL shouldRestoreScrollViewContentOffset;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@interface UITableView (PreviousNextIndexPath)
|
||||
|
||||
-(nullable NSIndexPath*)previousIndexPathOfIndexPath:(nonnull NSIndexPath*)indexPath;
|
||||
//-(nullable NSIndexPath*)nextIndexPathOfIndexPath:(nonnull NSIndexPath*)indexPath;
|
||||
|
||||
@end
|
||||
|
||||
@interface UICollectionView (PreviousNextIndexPath)
|
||||
|
||||
-(nullable NSIndexPath*)previousIndexPathOfIndexPath:(nonnull NSIndexPath*)indexPath;
|
||||
//-(nullable NSIndexPath*)nextIndexPathOfIndexPath:(nonnull NSIndexPath*)indexPath;
|
||||
|
||||
@end
|
||||
|
||||
@@ -51,3 +51,99 @@
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation UITableView (PreviousNextIndexPath)
|
||||
|
||||
-(nullable NSIndexPath*)previousIndexPathOfIndexPath:(nonnull NSIndexPath*)indexPath
|
||||
{
|
||||
NSInteger previousRow = indexPath.row - 1;
|
||||
NSInteger previousSection = indexPath.section;
|
||||
|
||||
//Fixing indexPath
|
||||
if (previousRow < 0)
|
||||
{
|
||||
previousSection -= 1;
|
||||
|
||||
if (previousSection >= 0)
|
||||
{
|
||||
previousRow = [self numberOfRowsInSection:previousSection]-1;
|
||||
}
|
||||
}
|
||||
|
||||
if (previousRow >= 0 && previousSection >= 0)
|
||||
{
|
||||
return [NSIndexPath indexPathForRow:previousRow inSection:previousSection];
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
//-(nullable NSIndexPath*)nextIndexPathOfIndexPath:(nonnull NSIndexPath*)indexPath
|
||||
//{
|
||||
// NSInteger nextRow = indexPath.row + 1;
|
||||
// NSInteger nextSection = indexPath.section;
|
||||
//
|
||||
// //Fixing indexPath
|
||||
// if (nextRow >= [self numberOfRowsInSection:nextSection])
|
||||
// {
|
||||
// nextRow = 0;
|
||||
// nextSection += 1;
|
||||
// }
|
||||
//
|
||||
// if (self.numberOfSections > nextSection && [self numberOfRowsInSection:nextSection] > nextRow)
|
||||
// {
|
||||
// return [NSIndexPath indexPathForItem:nextRow inSection:nextSection];
|
||||
// }
|
||||
//
|
||||
// return nil;
|
||||
//}
|
||||
//
|
||||
@end
|
||||
|
||||
@implementation UICollectionView (PreviousNextIndexPath)
|
||||
|
||||
-(nullable NSIndexPath*)previousIndexPathOfIndexPath:(nonnull NSIndexPath*)indexPath
|
||||
{
|
||||
NSInteger previousRow = indexPath.row - 1;
|
||||
NSInteger previousSection = indexPath.section;
|
||||
|
||||
//Fixing indexPath
|
||||
if (previousRow < 0)
|
||||
{
|
||||
previousSection -= 1;
|
||||
|
||||
if (previousSection >= 0)
|
||||
{
|
||||
previousRow = [self numberOfItemsInSection:previousSection]-1;
|
||||
}
|
||||
}
|
||||
|
||||
if (previousRow >= 0 && previousSection >= 0)
|
||||
{
|
||||
return [NSIndexPath indexPathForItem:previousRow inSection:previousSection];
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
//-(nullable NSIndexPath*)nextIndexPathOfIndexPath:(nonnull NSIndexPath*)indexPath
|
||||
//{
|
||||
// NSInteger nextRow = indexPath.row + 1;
|
||||
// NSInteger nextSection = indexPath.section;
|
||||
//
|
||||
// //Fixing indexPath
|
||||
// if (nextRow >= [self numberOfItemsInSection:nextSection])
|
||||
// {
|
||||
// nextRow = 0;
|
||||
// nextSection += 1;
|
||||
// }
|
||||
//
|
||||
// if (self.numberOfSections > nextSection && [self numberOfItemsInSection:nextSection] > nextRow)
|
||||
// {
|
||||
// return [NSIndexPath indexPathForItem:nextRow inSection:nextSection];
|
||||
// }
|
||||
//
|
||||
// return nil;
|
||||
//}
|
||||
|
||||
@end
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@
|
||||
{
|
||||
NSNumber *keyboardDistanceFromTextField = objc_getAssociatedObject(self, @selector(keyboardDistanceFromTextField));
|
||||
|
||||
return (keyboardDistanceFromTextField)?[keyboardDistanceFromTextField floatValue]:kIQUseDefaultKeyboardDistance;
|
||||
return (keyboardDistanceFromTextField != nil)?[keyboardDistanceFromTextField floatValue]:kIQUseDefaultKeyboardDistance;
|
||||
}
|
||||
|
||||
-(void)setIgnoreSwitchingByNextPrevious:(BOOL)ignoreSwitchingByNextPrevious
|
||||
|
||||
@@ -57,8 +57,13 @@
|
||||
|
||||
/**
|
||||
Returns the superView of provided class type.
|
||||
|
||||
@param classType class type of the object which is to be search in above hierarchy and return
|
||||
|
||||
@param belowView view object in upper hierarchy where method should stop searching and return nil
|
||||
*/
|
||||
-(nullable UIView*)superviewOfClassType:(nonnull Class)classType;
|
||||
-(nullable __kindof UIView*)superviewOfClassType:(nonnull Class)classType belowView:(nullable UIView*)belowView;
|
||||
-(nullable __kindof UIView*)superviewOfClassType:(nonnull Class)classType;
|
||||
|
||||
/**
|
||||
Returns all siblings of the receiver which canBecomeFirstResponder.
|
||||
@@ -77,7 +82,7 @@
|
||||
/**
|
||||
Returns searchBar if receiver object is UISearchBarTextField, otherwise return nil.
|
||||
*/
|
||||
@property (nullable, nonatomic, readonly) UISearchBar *searchBar;
|
||||
@property (nullable, nonatomic, readonly) UISearchBar *textFieldSearchBar;
|
||||
|
||||
/**
|
||||
Returns YES if the receiver object is UIAlertSheetTextField, otherwise return NO.
|
||||
|
||||
@@ -156,7 +156,12 @@
|
||||
return finalController;
|
||||
}
|
||||
|
||||
-(UIView*)superviewOfClassType:(Class)classType
|
||||
-(UIView*)superviewOfClassType:(nonnull Class)classType
|
||||
{
|
||||
return [self superviewOfClassType:classType belowView:nil];
|
||||
}
|
||||
|
||||
-(nullable __kindof UIView*)superviewOfClassType:(nonnull Class)classType belowView:(nullable UIView*)belowView
|
||||
{
|
||||
UIView *superview = self.superview;
|
||||
|
||||
@@ -184,6 +189,10 @@
|
||||
return superview;
|
||||
}
|
||||
}
|
||||
else if (belowView == superview)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
superview = superview.superview;
|
||||
}
|
||||
@@ -206,7 +215,7 @@
|
||||
|
||||
if (_IQcanBecomeFirstResponder == YES)
|
||||
{
|
||||
_IQcanBecomeFirstResponder = ([self isUserInteractionEnabled] && ![self isHidden] && [self alpha]!=0.0 && ![self isAlertViewTextField] && !self.searchBar);
|
||||
_IQcanBecomeFirstResponder = ([self isUserInteractionEnabled] && ![self isHidden] && [self alpha]!=0.0 && ![self isAlertViewTextField] && !self.textFieldSearchBar);
|
||||
}
|
||||
|
||||
return _IQcanBecomeFirstResponder;
|
||||
@@ -376,7 +385,7 @@
|
||||
return debugInfo;
|
||||
}
|
||||
|
||||
-(UISearchBar *)searchBar
|
||||
-(UISearchBar *)textFieldSearchBar
|
||||
{
|
||||
UIResponder *searchBar = [self nextResponder];
|
||||
|
||||
|
||||
-2
@@ -30,8 +30,6 @@
|
||||
/**
|
||||
Top/Bottom Layout constraint which help library to manage keyboardTextField distance
|
||||
|
||||
@message Library is internally handle Safe Area in iOS11 if `canAdjustAdditionalSafeAreaInsets = YES` and there is no need to do any tweak if you already migrated to use Safe Area
|
||||
|
||||
@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.
|
||||
*/
|
||||
@property(nullable, nonatomic, strong) IBOutlet NSLayoutConstraint *IQLayoutGuideConstraint __attribute__((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.")));
|
||||
|
||||
-2
@@ -25,6 +25,4 @@
|
||||
#define IQKeyboardManagerConstantsInternal_h
|
||||
|
||||
|
||||
#define IQ_IS_IOS10_OR_GREATER ([[NSProcessInfo processInfo] operatingSystemVersion].majorVersion >= 10)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -86,13 +86,6 @@ extern NSInteger const kIQPreviousNextButtonToolbarTag;
|
||||
*/
|
||||
@property(nonatomic, assign) CGFloat keyboardDistanceFromTextField;
|
||||
|
||||
/**
|
||||
Prevent keyboard manager to slide up the rootView to more than keyboard height. Default is YES.
|
||||
|
||||
Due to change in core-logic of handling distance between textField and keyboard distance, this tweak is no longer needed and things will just work out of the box for most of the cases.
|
||||
*/
|
||||
@property(nonatomic, assign) BOOL preventShowingBottomBlankSpace __attribute__((deprecated("Due to change in core-logic of handling distance between textField and keyboard distance, this tweak is no longer needed and things will just work out of the box for most of the cases. This property will be removed in future release.")));
|
||||
|
||||
/**
|
||||
Refreshes textField/textView position if any external changes is explicitly made by user.
|
||||
*/
|
||||
@@ -128,17 +121,17 @@ extern NSInteger const kIQPreviousNextButtonToolbarTag;
|
||||
@property(nonatomic, assign) IQAutoToolbarManageBehaviour toolbarManageBehaviour;
|
||||
|
||||
/**
|
||||
If YES, then uses textField's tintColor property for IQToolbar, otherwise tint color is black. Default is NO.
|
||||
If YES, then uses textField's tintColor property for IQToolbar, otherwise tint color is nil. Default is NO.
|
||||
*/
|
||||
@property(nonatomic, assign) BOOL shouldToolbarUsesTextFieldTintColor;
|
||||
|
||||
/**
|
||||
This is used for toolbar.tintColor when textfield.keyboardAppearance is UIKeyboardAppearanceDefault. If shouldToolbarUsesTextFieldTintColor is YES then this property is ignored. Default is nil and uses black color.
|
||||
This is used for toolbar.tintColor when textfield.keyboardAppearance is UIKeyboardAppearanceDefault. If shouldToolbarUsesTextFieldTintColor is YES then this property is ignored. Default is nil.
|
||||
*/
|
||||
@property(nullable, nonatomic, strong) UIColor *toolbarTintColor;
|
||||
|
||||
/**
|
||||
This is used for toolbar.barTintColor. Default is nil and uses white color.
|
||||
This is used for toolbar.barTintColor. Default is nil.
|
||||
*/
|
||||
@property(nullable, nonatomic, strong) UIColor *toolbarBarTintColor;
|
||||
|
||||
@@ -166,7 +159,6 @@ extern NSInteger const kIQPreviousNextButtonToolbarTag;
|
||||
/**
|
||||
If YES, then it add the textField's placeholder text on IQToolbar. Default is YES.
|
||||
*/
|
||||
@property(nonatomic, assign) BOOL shouldShowTextFieldPlaceholder __attribute__((deprecated("This is renamed to `shouldShowToolbarPlaceholder` for more clear naming.")));
|
||||
@property(nonatomic, assign) BOOL shouldShowToolbarPlaceholder;
|
||||
|
||||
/**
|
||||
@@ -180,7 +172,7 @@ extern NSInteger const kIQPreviousNextButtonToolbarTag;
|
||||
@property(nullable, nonatomic, strong) UIColor *placeholderColor;
|
||||
|
||||
/**
|
||||
Placeholder Button Color when it's treated as button. Default is nil. Which means iOS Blue for light toolbar and Yellow for dark toolbar
|
||||
Placeholder Button Color when it's treated as button. Default is nil
|
||||
*/
|
||||
@property(nullable, nonatomic, strong) UIColor *placeholderButtonColor;
|
||||
|
||||
@@ -258,26 +250,6 @@ extern NSInteger const kIQPreviousNextButtonToolbarTag;
|
||||
*/
|
||||
@property(nonatomic, assign) BOOL layoutIfNeededOnUpdate;
|
||||
|
||||
///-----------------------------------------------
|
||||
/// @name InteractivePopGestureRecognizer handling
|
||||
///-----------------------------------------------
|
||||
|
||||
/**
|
||||
If YES, then always consider UINavigationController.view begin point as {0,0}, this is a workaround to fix a bug #464 because there are no notification mechanism exist when UINavigationController.view.frame gets changed internally.
|
||||
*/
|
||||
@property(nonatomic, assign) BOOL shouldFixInteractivePopGestureRecognizer __attribute__((deprecated("Due to change in core-logic of handling distance between textField and keyboard distance, this tweak is no longer needed and things will just work out of the box for most of the cases. This property will be removed in future release.")));
|
||||
|
||||
#ifdef __IPHONE_11_0
|
||||
///---------------------------
|
||||
/// @name Safe Area
|
||||
///---------------------------
|
||||
|
||||
/**
|
||||
If YES, then library will try to adjust viewController.additionalSafeAreaInsets to automatically handle layout guide. Default is NO.
|
||||
*/
|
||||
@property(nonatomic, assign) BOOL canAdjustAdditionalSafeAreaInsets __attribute__((deprecated("Due to change in core-logic of handling distance between textField and keyboard distance, this safe area tweak is no longer needed and things will just work out of the box regardless of constraint pinned with safeArea/layoutGuide/superview. This property will be removed in future release.")));
|
||||
#endif
|
||||
|
||||
///---------------------------------------------
|
||||
/// @name Class Level enabling/disabling methods
|
||||
///---------------------------------------------
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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
|
||||
{
|
||||
|
||||
@@ -35,6 +35,11 @@
|
||||
*/
|
||||
@property(nullable, nonatomic,copy) IBInspectable NSString *placeholder;
|
||||
|
||||
/**
|
||||
Set textView's placeholder attributed text. Default is nil.
|
||||
*/
|
||||
@property(nullable, nonatomic,copy) IBInspectable NSAttributedString *attributedPlaceholder;
|
||||
|
||||
/**
|
||||
To set textView's placeholder text color. Default is nil.
|
||||
*/
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
@interface IQTextView ()
|
||||
|
||||
@property(nonatomic, strong) UILabel *placeholderLabel;
|
||||
@property(nullable, nonatomic, strong) UILabel *placeholderLabel;
|
||||
|
||||
@end
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
|
||||
-(void)refreshPlaceholder
|
||||
{
|
||||
if([[self text] length])
|
||||
if([[self text] length] || [[self attributedText] length])
|
||||
{
|
||||
[_placeholderLabel setAlpha:0];
|
||||
}
|
||||
@@ -87,6 +87,12 @@
|
||||
[self refreshPlaceholder];
|
||||
}
|
||||
|
||||
-(void)setAttributedText:(NSAttributedString *)attributedText
|
||||
{
|
||||
[super setAttributedText:attributedText];
|
||||
[self refreshPlaceholder];
|
||||
}
|
||||
|
||||
-(void)setFont:(UIFont *)font
|
||||
{
|
||||
[super setFont:font];
|
||||
@@ -119,6 +125,14 @@
|
||||
[self refreshPlaceholder];
|
||||
}
|
||||
|
||||
-(void)setAttributedPlaceholder:(NSAttributedString *)attributedPlaceholder
|
||||
{
|
||||
_attributedPlaceholder = attributedPlaceholder;
|
||||
|
||||
self.placeholderLabel.attributedText = attributedPlaceholder;
|
||||
[self refreshPlaceholder];
|
||||
}
|
||||
|
||||
-(void)setPlaceholderTextColor:(UIColor*)placeholderTextColor
|
||||
{
|
||||
_placeholderTextColor = placeholderTextColor;
|
||||
@@ -151,7 +165,16 @@
|
||||
_placeholderLabel.font = self.font;
|
||||
_placeholderLabel.textAlignment = self.textAlignment;
|
||||
_placeholderLabel.backgroundColor = [UIColor clearColor];
|
||||
_placeholderLabel.textColor = [UIColor colorWithWhite:0.7 alpha:1.0];
|
||||
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
|
||||
if (@available(iOS 13.0, *)) {
|
||||
_placeholderLabel.textColor = [UIColor systemGrayColor];
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
#if __IPHONE_OS_VERSION_MIN_REQUIRED < 130000
|
||||
_placeholderLabel.textColor = [UIColor lightTextColor];
|
||||
#endif
|
||||
}
|
||||
_placeholderLabel.alpha = 0;
|
||||
[self addSubview:_placeholderLabel];
|
||||
}
|
||||
|
||||
@@ -92,7 +92,6 @@
|
||||
-(void)dealloc
|
||||
{
|
||||
self.target = nil;
|
||||
self.invocation.target = nil;
|
||||
self.invocation = nil;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,8 +30,8 @@
|
||||
|
||||
@interface IQTitleBarButtonItem ()
|
||||
|
||||
@property(nonatomic, strong) UIView *titleView;
|
||||
@property(nonatomic, strong) UIButton *titleButton;
|
||||
@property(nullable, nonatomic, strong) UIView *titleView;
|
||||
@property(nullable, nonatomic, strong) UIButton *titleButton;
|
||||
|
||||
@end
|
||||
|
||||
@@ -48,7 +48,16 @@
|
||||
_titleButton = [UIButton buttonWithType:UIButtonTypeSystem];
|
||||
_titleButton.enabled = NO;
|
||||
_titleButton.titleLabel.numberOfLines = 3;
|
||||
[_titleButton setTitleColor:[UIColor colorWithRed:0.0 green:0.5 blue:1.0 alpha:1.0] forState:UIControlStateNormal];
|
||||
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
|
||||
if (@available(iOS 13.0, *)) {
|
||||
[_titleButton setTitleColor:[UIColor systemBlueColor] forState:UIControlStateNormal];
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
#if __IPHONE_OS_VERSION_MIN_REQUIRED < 130000
|
||||
[_titleButton setTitleColor:[UIColor colorWithRed:0.0 green:0.5 blue:1.0 alpha:1.0] forState:UIControlStateNormal];
|
||||
#endif
|
||||
}
|
||||
[_titleButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateDisabled];
|
||||
[_titleButton setBackgroundColor:[UIColor clearColor]];
|
||||
[_titleButton.titleLabel setTextAlignment:NSTextAlignmentCenter];
|
||||
@@ -56,7 +65,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 +89,6 @@
|
||||
[_titleView addConstraints:@[top,bottom,leading,trailing]];
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
_titleView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
|
||||
_titleButton.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
|
||||
@@ -121,7 +128,16 @@
|
||||
-(void)setSelectableTitleColor:(UIColor*)selectableTitleColor
|
||||
{
|
||||
_selectableTitleColor = selectableTitleColor;
|
||||
[_titleButton setTitleColor:_selectableTitleColor?:[UIColor colorWithRed:0.0 green:0.5 blue:1.0 alpha:1.0] forState:UIControlStateNormal];
|
||||
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
|
||||
if (@available(iOS 13.0, *)) {
|
||||
[_titleButton setTitleColor:_selectableTitleColor?:[UIColor systemBlueColor] forState:UIControlStateNormal];
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
#if __IPHONE_OS_VERSION_MIN_REQUIRED < 130000
|
||||
[_titleButton setTitleColor:_selectableTitleColor?:[UIColor colorWithRed:0.0 green:0.5 blue:1.0 alpha:1.0] forState:UIControlStateNormal];
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
-(void)setInvocation:(NSInvocation *)invocation
|
||||
|
||||
@@ -29,12 +29,6 @@
|
||||
#import <UIKit/UIAccessibility.h>
|
||||
#import <UIKit/UIViewController.h>
|
||||
|
||||
@interface IQTitleBarButtonItem (PrivateAccessor)
|
||||
|
||||
@property(nonatomic, strong) UIButton *titleButton;
|
||||
|
||||
@end
|
||||
|
||||
@implementation IQToolbar
|
||||
@synthesize previousBarButton = _previousBarButton;
|
||||
@synthesize nextBarButton = _nextBarButton;
|
||||
@@ -89,11 +83,6 @@
|
||||
-(void)dealloc
|
||||
{
|
||||
self.items = nil;
|
||||
_previousBarButton = nil;
|
||||
_nextBarButton = nil;
|
||||
_titleBarButton = nil;
|
||||
_doneBarButton = nil;
|
||||
_fixedSpaceBarButton = nil;
|
||||
}
|
||||
|
||||
-(IQBarButtonItem *)previousBarButton
|
||||
@@ -101,7 +90,7 @@
|
||||
if (_previousBarButton == nil)
|
||||
{
|
||||
_previousBarButton = [[IQBarButtonItem alloc] initWithImage:nil style:UIBarButtonItemStylePlain target:nil action:nil];
|
||||
_previousBarButton.accessibilityLabel = @"Toolbar Previous Button";
|
||||
_previousBarButton.accessibilityLabel = @"Previous";
|
||||
}
|
||||
|
||||
return _previousBarButton;
|
||||
@@ -112,7 +101,7 @@
|
||||
if (_nextBarButton == nil)
|
||||
{
|
||||
_nextBarButton = [[IQBarButtonItem alloc] initWithImage:nil style:UIBarButtonItemStylePlain target:nil action:nil];
|
||||
_nextBarButton.accessibilityLabel = @"Toolbar Next Button";
|
||||
_nextBarButton.accessibilityLabel = @"Next";
|
||||
}
|
||||
|
||||
return _nextBarButton;
|
||||
@@ -123,7 +112,7 @@
|
||||
if (_titleBarButton == nil)
|
||||
{
|
||||
_titleBarButton = [[IQTitleBarButtonItem alloc] initWithTitle:nil];
|
||||
_titleBarButton.accessibilityLabel = @"Toolbar Title Button";
|
||||
_titleBarButton.accessibilityLabel = @"Title";
|
||||
}
|
||||
|
||||
return _titleBarButton;
|
||||
@@ -134,7 +123,7 @@
|
||||
if (_doneBarButton == nil)
|
||||
{
|
||||
_doneBarButton = [[IQBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:nil action:nil];
|
||||
_doneBarButton.accessibilityLabel = @"Toolbar Done Button";
|
||||
_doneBarButton.accessibilityLabel = @"Done";
|
||||
}
|
||||
|
||||
return _doneBarButton;
|
||||
@@ -145,18 +134,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;
|
||||
@@ -171,23 +156,6 @@
|
||||
return sizeThatFit;
|
||||
}
|
||||
|
||||
-(void)setBarStyle:(UIBarStyle)barStyle
|
||||
{
|
||||
[super setBarStyle:barStyle];
|
||||
|
||||
if (self.titleBarButton.selectableTitleColor == nil)
|
||||
{
|
||||
if (barStyle == UIBarStyleDefault)
|
||||
{
|
||||
[self.titleBarButton.titleButton setTitleColor:[UIColor colorWithRed:0.0 green:0.5 blue:1.0 alpha:1.0] forState:UIControlStateNormal];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self.titleBarButton.titleButton setTitleColor:[UIColor yellowColor] forState:UIControlStateNormal];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-(void)setTintColor:(UIColor *)tintColor
|
||||
{
|
||||
[super setTintColor:tintColor];
|
||||
@@ -202,12 +170,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;
|
||||
|
||||
|
||||
+9
-12
@@ -28,9 +28,9 @@
|
||||
|
||||
@interface IQBarButtonItemConfiguration : NSObject
|
||||
|
||||
-(instancetype)initWithBarButtonSystemItem:(UIBarButtonSystemItem)barButtonSystemItem action:(nullable SEL)action;
|
||||
-(instancetype)initWithImage:(nonnull UIImage*)image action:(nullable SEL)action;
|
||||
-(instancetype)initWithTitle:(nonnull NSString*)title action:(nullable SEL)action;
|
||||
-(nonnull instancetype)initWithBarButtonSystemItem:(UIBarButtonSystemItem)barButtonSystemItem action:(nullable SEL)action;
|
||||
-(nonnull instancetype)initWithImage:(nonnull UIImage*)image action:(nullable SEL)action;
|
||||
-(nonnull instancetype)initWithTitle:(nonnull NSString*)title action:(nullable SEL)action;
|
||||
|
||||
@property (readonly, nonatomic) UIBarButtonSystemItem barButtonSystemItem; //System Item to be used to instantiate bar button
|
||||
@property (readonly, nonatomic, nullable) UIImage *image; //Image to show on bar button item if it's not a system item.
|
||||
@@ -41,13 +41,13 @@
|
||||
|
||||
@interface UIImage (IQKeyboardToolbarNextPreviousImage)
|
||||
|
||||
+(UIImage*)keyboardPreviousiOS9Image;
|
||||
+(UIImage*)keyboardNextiOS9Image;
|
||||
+(UIImage*)keyboardPreviousiOS10Image;
|
||||
+(UIImage*)keyboardNextiOS10Image;
|
||||
+(nullable UIImage*)keyboardPreviousiOS9Image;
|
||||
+(nullable UIImage*)keyboardNextiOS9Image;
|
||||
+(nullable UIImage*)keyboardPreviousiOS10Image;
|
||||
+(nullable UIImage*)keyboardNextiOS10Image;
|
||||
|
||||
+(UIImage*)keyboardPreviousImage;
|
||||
+(UIImage*)keyboardNextImage;
|
||||
+(nullable UIImage*)keyboardPreviousImage;
|
||||
+(nullable UIImage*)keyboardNextImage;
|
||||
|
||||
@end
|
||||
|
||||
@@ -69,19 +69,16 @@
|
||||
If `shouldHideToolbarPlaceholder` is YES, then title will not be added to the toolbar. Default to NO.
|
||||
*/
|
||||
@property (assign, nonatomic) BOOL shouldHideToolbarPlaceholder;
|
||||
@property (assign, nonatomic) BOOL shouldHidePlaceholderText __attribute__((deprecated("This is renamed to `shouldHideToolbarPlaceholder` for more clear naming.")));
|
||||
|
||||
/**
|
||||
`toolbarPlaceholder` to override default `placeholder` text when drawing text on toolbar.
|
||||
*/
|
||||
@property (nullable, strong, nonatomic) NSString* toolbarPlaceholder;
|
||||
@property (nullable, strong, nonatomic) NSString* placeholderText __attribute__((deprecated("This is renamed to `toolbarPlaceholder` for more clear naming.")));
|
||||
|
||||
/**
|
||||
`drawingToolbarPlaceholder` will be actual text used to draw on toolbar. This would either `placeholder` or `toolbarPlaceholder`.
|
||||
*/
|
||||
@property (nullable, strong, nonatomic, readonly) NSString* drawingToolbarPlaceholder;
|
||||
@property (nullable, strong, nonatomic, readonly) NSString* drawingPlaceholderText __attribute__((deprecated("This is renamed to `drawingToolbarPlaceholder` for more clear naming.")));
|
||||
|
||||
///-------------
|
||||
/// MARK: Common
|
||||
|
||||
+18
-51
@@ -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];
|
||||
}
|
||||
@@ -277,16 +253,6 @@
|
||||
return [shouldHideToolbarPlaceholder boolValue];
|
||||
}
|
||||
|
||||
-(void)setShouldHidePlaceholderText:(BOOL)shouldHidePlaceholderText
|
||||
{
|
||||
[self setShouldHideToolbarPlaceholder:shouldHidePlaceholderText];
|
||||
}
|
||||
|
||||
-(BOOL)shouldHidePlaceholderText
|
||||
{
|
||||
return [self shouldHideToolbarPlaceholder];
|
||||
}
|
||||
|
||||
-(void)setToolbarPlaceholder:(NSString *)toolbarPlaceholder
|
||||
{
|
||||
objc_setAssociatedObject(self, @selector(toolbarPlaceholder), toolbarPlaceholder, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||
@@ -300,16 +266,6 @@
|
||||
return toolbarPlaceholder;
|
||||
}
|
||||
|
||||
-(void)setPlaceholderText:(NSString*)placeholderText
|
||||
{
|
||||
[self setToolbarPlaceholder:placeholderText];
|
||||
}
|
||||
|
||||
-(NSString*)placeholderText
|
||||
{
|
||||
return [self toolbarPlaceholder];
|
||||
}
|
||||
|
||||
-(NSString *)drawingToolbarPlaceholder
|
||||
{
|
||||
if (self.shouldHideToolbarPlaceholder)
|
||||
@@ -330,11 +286,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
-(NSString*)drawingPlaceholderText
|
||||
{
|
||||
return [self drawingToolbarPlaceholder];
|
||||
}
|
||||
|
||||
#pragma mark - Private helper
|
||||
|
||||
+(IQBarButtonItem*)flexibleBarButtonItem
|
||||
@@ -377,6 +328,8 @@
|
||||
prev = [[IQBarButtonItem alloc] initWithImage:previousBarButtonConfiguration.image style:UIBarButtonItemStylePlain target:target action:previousBarButtonConfiguration.action];
|
||||
prev.invocation = toolbar.previousBarButton.invocation;
|
||||
prev.accessibilityLabel = toolbar.previousBarButton.accessibilityLabel;
|
||||
prev.enabled = toolbar.previousBarButton.enabled;
|
||||
prev.tag = toolbar.previousBarButton.tag;
|
||||
toolbar.previousBarButton = prev;
|
||||
}
|
||||
else if (previousBarButtonConfiguration.title)
|
||||
@@ -384,6 +337,8 @@
|
||||
prev = [[IQBarButtonItem alloc] initWithTitle:previousBarButtonConfiguration.title style:UIBarButtonItemStylePlain target:target action:previousBarButtonConfiguration.action];
|
||||
prev.invocation = toolbar.previousBarButton.invocation;
|
||||
prev.accessibilityLabel = toolbar.previousBarButton.accessibilityLabel;
|
||||
prev.enabled = toolbar.previousBarButton.enabled;
|
||||
prev.tag = toolbar.previousBarButton.tag;
|
||||
toolbar.previousBarButton = prev;
|
||||
}
|
||||
else
|
||||
@@ -391,6 +346,8 @@
|
||||
prev = [[IQBarButtonItem alloc] initWithBarButtonSystemItem:previousBarButtonConfiguration.barButtonSystemItem target:target action:previousBarButtonConfiguration.action];
|
||||
prev.invocation = toolbar.previousBarButton.invocation;
|
||||
prev.accessibilityLabel = toolbar.previousBarButton.accessibilityLabel;
|
||||
prev.enabled = toolbar.previousBarButton.enabled;
|
||||
prev.tag = toolbar.previousBarButton.tag;
|
||||
toolbar.previousBarButton = prev;
|
||||
}
|
||||
|
||||
@@ -418,6 +375,8 @@
|
||||
next = [[IQBarButtonItem alloc] initWithImage:nextBarButtonConfiguration.image style:UIBarButtonItemStylePlain target:target action:nextBarButtonConfiguration.action];
|
||||
next.invocation = toolbar.nextBarButton.invocation;
|
||||
next.accessibilityLabel = toolbar.nextBarButton.accessibilityLabel;
|
||||
next.enabled = toolbar.nextBarButton.enabled;
|
||||
next.tag = toolbar.nextBarButton.tag;
|
||||
toolbar.nextBarButton = next;
|
||||
}
|
||||
else if (nextBarButtonConfiguration.title)
|
||||
@@ -425,6 +384,8 @@
|
||||
next = [[IQBarButtonItem alloc] initWithTitle:nextBarButtonConfiguration.title style:UIBarButtonItemStylePlain target:target action:nextBarButtonConfiguration.action];
|
||||
next.invocation = toolbar.nextBarButton.invocation;
|
||||
next.accessibilityLabel = toolbar.nextBarButton.accessibilityLabel;
|
||||
next.enabled = toolbar.nextBarButton.enabled;
|
||||
next.tag = toolbar.nextBarButton.tag;
|
||||
toolbar.nextBarButton = next;
|
||||
}
|
||||
else
|
||||
@@ -432,6 +393,8 @@
|
||||
next = [[IQBarButtonItem alloc] initWithBarButtonSystemItem:nextBarButtonConfiguration.barButtonSystemItem target:target action:nextBarButtonConfiguration.action];
|
||||
next.invocation = toolbar.nextBarButton.invocation;
|
||||
next.accessibilityLabel = toolbar.nextBarButton.accessibilityLabel;
|
||||
next.enabled = toolbar.nextBarButton.enabled;
|
||||
next.tag = toolbar.nextBarButton.tag;
|
||||
toolbar.nextBarButton = next;
|
||||
}
|
||||
|
||||
@@ -445,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;
|
||||
}
|
||||
@@ -474,6 +435,8 @@
|
||||
done = [[IQBarButtonItem alloc] initWithImage:rightBarButtonConfiguration.image style:UIBarButtonItemStylePlain target:target action:rightBarButtonConfiguration.action];
|
||||
done.invocation = toolbar.doneBarButton.invocation;
|
||||
done.accessibilityLabel = toolbar.doneBarButton.accessibilityLabel;
|
||||
done.enabled = toolbar.doneBarButton.enabled;
|
||||
done.tag = toolbar.doneBarButton.tag;
|
||||
toolbar.doneBarButton = done;
|
||||
}
|
||||
else if (rightBarButtonConfiguration.title)
|
||||
@@ -481,6 +444,8 @@
|
||||
done = [[IQBarButtonItem alloc] initWithTitle:rightBarButtonConfiguration.title style:UIBarButtonItemStylePlain target:target action:rightBarButtonConfiguration.action];
|
||||
done.invocation = toolbar.doneBarButton.invocation;
|
||||
done.accessibilityLabel = toolbar.doneBarButton.accessibilityLabel;
|
||||
done.enabled = toolbar.doneBarButton.enabled;
|
||||
done.tag = toolbar.doneBarButton.tag;
|
||||
toolbar.doneBarButton = done;
|
||||
}
|
||||
else
|
||||
@@ -488,6 +453,8 @@
|
||||
done = [[IQBarButtonItem alloc] initWithBarButtonSystemItem:rightBarButtonConfiguration.barButtonSystemItem target:target action:rightBarButtonConfiguration.action];
|
||||
done.invocation = toolbar.doneBarButton.invocation;
|
||||
done.accessibilityLabel = toolbar.doneBarButton.accessibilityLabel;
|
||||
done.enabled = toolbar.doneBarButton.enabled;
|
||||
done.tag = toolbar.doneBarButton.tag;
|
||||
toolbar.doneBarButton = done;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user