热点连接流程修改

This commit is contained in:
wbzhan
2019-09-21 17:29:16 +08:00
parent 9342faecbc
commit 41e5233e1f
65 changed files with 2363 additions and 651 deletions
@@ -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;
@@ -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
@@ -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;
}