How to use AutoScrollLabel in UILabel inside inputAccessoryView when the keyboard appears. I seem to have difficulties using it because I don't use an IB method to connect it to the code. I do this programatically. I have imported the .h file of AutoScrollView and it gives me errors. Find the AutoScrollLabel here
This is my code for the inputAccessoryView.
- (void)viewDidLoad
{
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake
(0, 0, 320, 23)];
label.backgroundColor = [UIColor clearColor];
label.shadowOffset = CGSizeMake(0, 1);
label.text = @"24 Hour time format only!";
label.font = [UIFont systemFontOfSize:17.0];
[label setTextColor:[UIColor whiteColor]];
UIBarButtonItem *text2 = [[UIBarButtonItem alloc] initWithCustomView:label];
UIToolbar* numberToolbar = [[UIToolbar alloc]init];
numberToolbar.barStyle = UIBarStyleBlackOpaque;
numberToolbar.items = [NSArray arrayWithObjects:text2, nil];
[numberToolbar sizeToFit];
In my example, I've created label with xib, then I add it into keyboard acc when it's appear.
Declare label like
In
viewDidLoad
Then,add code to textfield delegate method
textFieldDidBeginEditing:
as belowAnd finally, add code to
textFieldDidBeginEditing:
as below