26
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

posted at

updated at

iOSの標準キーボード上に情報を表示する方法

拙作のArrow NoteのiPhone版では、画面を節約するため、標準キーボードの上に文字数などの情報をはみ出して表示しています。その方法を共有します。

ObjectiveC
@interface ViewController : UIViewController
@property IBOutlet UITextView *textView;
@end

@implementation ViewController
- (void)viewDidLoad
{
    [super viewDidLoad];
    UIView *inputAccessoryView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
    inputAccessoryView.clipsToBounds = NO;
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 44, 100, 22)];
    label.text = @"Hello, World";
    [inputAccessoryView addSubview:label];
    self.textView.inputAccessoryView = inputAccessoryView;
}
@end
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Sign upLogin
26
Help us understand the problem. What are the problem?