Adopted keyboard appearance style for automatic IQToolbar

This commit is contained in:
hackiftekhar
2015-01-19 00:25:55 +05:30
parent 291f242c71
commit 8023075fa2
5 changed files with 97 additions and 33 deletions

View File

@@ -41,7 +41,7 @@
/*! https://github.com/kif-framework/KIF/blob/master/Additions/LoadableCategory.h
@discussion To load categories in the current file loadable without using "-load-all" flag. When we try to create framework or library the compilers skips linking files that contain only categories. So user this macro to add a dummy class, which causes the linker to add the file. You will also need to add "-ObjC" to the "Other Linker Flags" build setting in any project that uses the framework.
@discussion To load categories in the current file loadable without using "-load-all" flag. When we try to create framework or library the compilers skips linking files that contain only categories. So use this macro to add a dummy class, which causes the linker to add the file. You will also need to add "-ObjC" to the "Other Linker Flags" build setting in any project that uses the framework.
@param UNIQUE_NAME A globally unique name.
*/

View File

@@ -1295,20 +1295,40 @@ void _IQShowLog(NSString *logString);
[textField addDoneOnKeyboardWithTarget:self action:@selector(doneAction:) shouldShowPlaceholder:_shouldShowTextFieldPlaceholder];
textField.inputAccessoryView.tag = kIQDoneButtonToolbarTag; // (Bug ID: #78)
//Setting toolbar tintColor // (Enhancement ID: #30)
if (_shouldToolbarUsesTextFieldTintColor && [textField respondsToSelector:@selector(tintColor)])
[textField.inputAccessoryView setTintColor:[textField tintColor]];
//Setting toolbar title font. // (Enhancement ID: #30)
if (_shouldShowTextFieldPlaceholder && _placeholderFont && [_placeholderFont isKindOfClass:[UIFont class]])
[(IQToolbar*)[textField inputAccessoryView] setTitleFont:_placeholderFont];
if ([textField respondsToSelector:@selector(keyboardAppearance)])
{
IQToolbar *toolbar = (IQToolbar*)[textField inputAccessoryView];
switch ([(UITextField*)textField keyboardAppearance])
{
case UIKeyboardAppearanceAlert:
{
toolbar.barStyle = UIBarStyleBlack;
if ([toolbar respondsToSelector:@selector(tintColor)])
[toolbar setTintColor:[UIColor whiteColor]];
}
break;
default:
{
toolbar.barStyle = UIBarStyleDefault;
//Setting toolbar tintColor // (Enhancement ID: #30)
if (_shouldToolbarUsesTextFieldTintColor && [toolbar respondsToSelector:@selector(tintColor)])
[toolbar setTintColor:[textField tintColor]];
}
break;
}
}
}
}
else if(siblings.count)
{
// If more than 1 textField is found. then adding previous/next/done buttons on it.
for (UITextField *textField in siblings)
{
//Setting toolbar title font. // (Enhancement ID: #30)
if (_shouldShowTextFieldPlaceholder && _placeholderFont && [_placeholderFont isKindOfClass:[UIFont class]])
[(IQToolbar*)[textField inputAccessoryView] setTitleFont:_placeholderFont];
}
else if(siblings.count)
{
// If more than 1 textField is found. then adding previous/next/done buttons on it.
for (UITextField *textField in siblings)
{
//Either there is no inputAccessoryView or if accessoryView is not appropriate for current situation(There is Done toolbar).
if (![textField inputAccessoryView] || [[textField inputAccessoryView] tag] == kIQDoneButtonToolbarTag)
{
@@ -1316,9 +1336,29 @@ void _IQShowLog(NSString *logString);
[textField addPreviousNextDoneOnKeyboardWithTarget:self previousAction:@selector(previousAction:) nextAction:@selector(nextAction:) doneAction:@selector(doneAction:) shouldShowPlaceholder:_shouldShowTextFieldPlaceholder];
textField.inputAccessoryView.tag = kIQPreviousNextButtonToolbarTag; // (Bug ID: #78)
//Setting toolbar tintColor // (Enhancement ID: #30)
if (_shouldToolbarUsesTextFieldTintColor && [textField respondsToSelector:@selector(tintColor)])
[textField.inputAccessoryView setTintColor:[textField tintColor]];
if ([textField respondsToSelector:@selector(keyboardAppearance)])
{
IQToolbar *toolbar = (IQToolbar*)[textField inputAccessoryView];
switch ([(UITextField*)textField keyboardAppearance])
{
case UIKeyboardAppearanceAlert:
{
toolbar.barStyle = UIBarStyleBlack;
if ([toolbar respondsToSelector:@selector(tintColor)])
[toolbar setTintColor:[UIColor whiteColor]];
}
break;
default:
{
toolbar.barStyle = UIBarStyleDefault;
//Setting toolbar tintColor // (Enhancement ID: #30)
if (_shouldToolbarUsesTextFieldTintColor && [toolbar respondsToSelector:@selector(tintColor)])
[toolbar setTintColor:[textField tintColor]];
}
break;
}
}
//Setting toolbar title font. // (Enhancement ID: #30)
if (_shouldShowTextFieldPlaceholder && _placeholderFont && [_placeholderFont isKindOfClass:[UIFont class]])

View File

@@ -24,13 +24,6 @@
#import <UIKit/UIView.h>
///* @const kIQRightButtonToolbarTag Default tag for toolbar with Right button -1001. */
//extern NSInteger const kIQRightButtonToolbarTag;
///* @const kIQRightLeftButtonToolbarTag Default tag for toolbar with Right/Left buttons -1003. */
//extern NSInteger const kIQRightLeftButtonToolbarTag;
///* @const kIQCancelDoneButtonToolbarTag Default tag for toolbar with Cancel/Done buttons -1004. */
//extern NSInteger const kIQCancelDoneButtonToolbarTag;
@class UIBarButtonItem;
/*!

View File

@@ -35,10 +35,6 @@
IQ_LoadCategory(IQUIViewToolbar)
//NSInteger const kIQRightButtonToolbarTag = -1001;
//NSInteger const kIQRightLeftButtonToolbarTag = -1003;
//NSInteger const kIQCancelDoneButtonToolbarTag = -1004;
/*UIKeyboardToolbar Category implementation*/
@implementation UIView (IQToolbarAddition)
@@ -121,7 +117,14 @@ IQ_LoadCategory(IQUIViewToolbar)
// Creating a toolBar for keyboard
IQToolbar *toolbar = [[IQToolbar alloc] init];
// toolbar.tag = kIQRightButtonToolbarTag;
if ([self respondsToSelector:@selector(keyboardAppearance)])
{
switch ([(UITextField*)self keyboardAppearance])
{
case UIKeyboardAppearanceAlert: toolbar.barStyle = UIBarStyleBlack; break;
default: toolbar.barStyle = UIBarStyleDefault; break;
}
}
NSMutableArray *items = [[NSMutableArray alloc] init];
@@ -187,7 +190,14 @@ IQ_LoadCategory(IQUIViewToolbar)
// Creating a toolBar for keyboard
IQToolbar *toolbar = [[IQToolbar alloc] init];
// toolbar.tag = kIQDoneButtonToolbarTag;
if ([self respondsToSelector:@selector(keyboardAppearance)])
{
switch ([(UITextField*)self keyboardAppearance])
{
case UIKeyboardAppearanceAlert: toolbar.barStyle = UIBarStyleBlack; break;
default: toolbar.barStyle = UIBarStyleDefault; break;
}
}
NSMutableArray *items = [[NSMutableArray alloc] init];
@@ -254,7 +264,14 @@ IQ_LoadCategory(IQUIViewToolbar)
// Creating a toolBar for keyboard
IQToolbar *toolbar = [[IQToolbar alloc] init];
// toolbar.tag = kIQRightLeftButtonToolbarTag;
if ([self respondsToSelector:@selector(keyboardAppearance)])
{
switch ([(UITextField*)self keyboardAppearance])
{
case UIKeyboardAppearanceAlert: toolbar.barStyle = UIBarStyleBlack; break;
default: toolbar.barStyle = UIBarStyleDefault; break;
}
}
NSMutableArray *items = [[NSMutableArray alloc] init];
@@ -325,7 +342,14 @@ IQ_LoadCategory(IQUIViewToolbar)
// Creating a toolBar for keyboard
IQToolbar *toolbar = [[IQToolbar alloc] init];
// toolbar.tag = kIQCancelDoneButtonToolbarTag;
if ([self respondsToSelector:@selector(keyboardAppearance)])
{
switch ([(UITextField*)self keyboardAppearance])
{
case UIKeyboardAppearanceAlert: toolbar.barStyle = UIBarStyleBlack; break;
default: toolbar.barStyle = UIBarStyleDefault; break;
}
}
NSMutableArray *items = [[NSMutableArray alloc] init];
@@ -396,7 +420,14 @@ IQ_LoadCategory(IQUIViewToolbar)
// Creating a toolBar for phoneNumber keyboard
IQToolbar *toolbar = [[IQToolbar alloc] init];
// toolbar.tag = kIQPreviousNextButtonToolbarTag;
if ([self respondsToSelector:@selector(keyboardAppearance)])
{
switch ([(UITextField*)self keyboardAppearance])
{
case UIKeyboardAppearanceAlert: toolbar.barStyle = UIBarStyleBlack; break;
default: toolbar.barStyle = UIBarStyleDefault; break;
}
}
NSMutableArray *items = [[NSMutableArray alloc] init];