Created
January 5, 2015 18:45
-
-
Save jiro/826e812ddacf445f06be to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "KeyboardViewController.h" | |
@interface KeyboardViewController () | |
@end | |
@implementation KeyboardViewController | |
- (void)updateViewConstraints { | |
[super updateViewConstraints]; | |
// Add custom view sizing constraints here | |
} | |
- (void)viewDidLoad { | |
[super viewDidLoad]; | |
// Perform custom UI setup here | |
self.nextKeyboardButton = [UIButton buttonWithType:UIButtonTypeSystem]; | |
[self.nextKeyboardButton setTitle:NSLocalizedString(@"Next Keyboard", @"Title for 'Next Keyboard' button") forState:UIControlStateNormal]; | |
[self.nextKeyboardButton sizeToFit]; | |
self.nextKeyboardButton.translatesAutoresizingMaskIntoConstraints = NO; | |
[self.nextKeyboardButton addTarget:self action:@selector(advanceToNextInputMode) forControlEvents:UIControlEventTouchUpInside]; | |
[self.view addSubview:self.nextKeyboardButton]; | |
NSLayoutConstraint *nextKeyboardButtonLeftSideConstraint = [NSLayoutConstraint constraintWithItem:self.nextKeyboardButton attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0.0]; | |
NSLayoutConstraint *nextKeyboardButtonBottomConstraint = [NSLayoutConstraint constraintWithItem:self.nextKeyboardButton attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0.0]; | |
[self.view addConstraints:@[nextKeyboardButtonLeftSideConstraint, nextKeyboardButtonBottomConstraint]]; | |
} | |
- (void)didReceiveMemoryWarning { | |
[super didReceiveMemoryWarning]; | |
// Dispose of any resources that can be recreated | |
} | |
- (void)textWillChange:(id<UITextInput>)textInput { | |
// The app is about to change the document's contents. Perform any preparation here. | |
} | |
- (void)textDidChange:(id<UITextInput>)textInput { | |
// The app has just changed the document's contents, the document context has been updated. | |
UIColor *textColor = nil; | |
if (self.textDocumentProxy.keyboardAppearance == UIKeyboardAppearanceDark) { | |
textColor = [UIColor whiteColor]; | |
} else { | |
textColor = [UIColor blackColor]; | |
} | |
[self.nextKeyboardButton setTitleColor:textColor forState:UIControlStateNormal]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment