Created
January 18, 2014 11:00
-
-
Save yutopio/8488962 to your computer and use it in GitHub Desktop.
Multiline Textbox for iOS 7.
This file contains 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
// | |
// YTOMultilineTextbox.m | |
// MultilineTextbox | |
// | |
// Created by Yuto Takei on 1/18/14. | |
// Copyright (c) 2014 Yuto Takei. All rights reserved. | |
// | |
@interface YTOMultilineTextbox : UITextView | |
@end | |
@implementation YTOMultilineTextbox | |
- (id)init | |
{ | |
self = [super init]; | |
[self initInterface]; | |
return self; | |
} | |
- (id)initWithFrame:(CGRect)frame | |
{ | |
self = [super initWithFrame:frame]; | |
[self initInterface]; | |
return self; | |
} | |
- (id)initWithCoder:(NSCoder *)aDecoder | |
{ | |
self = [super initWithCoder:aDecoder]; | |
[self initInterface]; | |
return self; | |
} | |
- (void)initInterface | |
{ | |
self.layer.borderColor = [UIColor blackColor].CGColor; | |
self.layer.borderWidth = 1; | |
UIToolbar *toolbar = [[UIToolbar alloc] init]; | |
toolbar.barStyle = UIBarStyleDefault; | |
[toolbar sizeToFit]; | |
UIBarButtonItem *close = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:NULL action:@selector(closeKeyboard)]; | |
toolbar.tintColor = [UIColor blueColor]; | |
[toolbar setItems:[[NSArray alloc] initWithObjects:[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:NULL action:NULL], close, nil]]; | |
self.inputAccessoryView = toolbar; | |
} | |
- (void)closeKeyboard | |
{ | |
[self resignFirstResponder]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment