Skip to content

Instantly share code, notes, and snippets.

@yutopio
Created January 18, 2014 11:00
Show Gist options
  • Save yutopio/8488962 to your computer and use it in GitHub Desktop.
Save yutopio/8488962 to your computer and use it in GitHub Desktop.
Multiline Textbox for iOS 7.
//
// 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