How to expand gradient keyboard on iPhone?

I see several applications expanding the keyboard, but I would like to know how they do it.

Here are two examples.

Textastic and Tooltip

Now I know that I can add inputAccessoryView to a UITextView, but it still has a small thin line that separates the keyboard from the UIToolbar, as in the picture below.

enter image description here

How do they do it? A UIWindow extension that contains a keyboard or in some other way?

Update 1 with the answer:

So, I used the solution that Tyraz wrote.

  • Subclass of UIToolbar
  • Instead of an image, I used a UIView with the background color the same as the keyboard gradient completion color, and with UIViewAutoResizingMaskFlexibleWidth so that it closes the keyboard when rotated with a height of 3 pixels.

Here is the code for a subclass of UIToolbar

- (void)didMoveToSuperview { [self.separatorHideView removeFromSuperview]; CGRect seperatorRect = CGRectMake(self.frame.origin.x, self.frame.size.height, self.frame.size.width, 3.0); self.separatorHideView = [[UIView alloc]]; self.separatorHideView.backgroundColor = [UIColor colorWithRed:0.569 green:0.600 blue:0.643 alpha:1.000]; self.separatorHideView.autoresizingMask = UIViewAutoresizingFlexibleWidth; [self addSubview:self.separatorHideView]; } 

Update 2: Here is the code, how I add it to a UITextView and what color I use for shades.

I add it to a UITextView in viewDidLoad with the following code

  CustomToolbar *accessoryToolbar = [[CustomToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 38)]; accessoryToolbar.tintColor = [UIColor colorWithRed:0.569 green:0.600 blue:0.643 alpha:1.000]; editor.inputAccessoryView = accessoryToolbar; 

And this is how it looks with the help of the solution applied to it

enter image description here

+6
source share
2 answers

I would try using inputAccessoryView plus a second view that sits on top of the separator line and "fills the space".

Once the inputAccessoryView has been added to the keyboard (overwrite the didMoveToSuperview method in your UIView subclass for accessories to be notified when this happens), add it to the inputAccessoryView supervisor.

Your helper subclass of UIView should have something like this:

 - (void)didMoveToSuperview { [self.separatorHideView removeFromSuperview]; CGRect seperatorRect = CGRectMake(self.frame.origin.x, self.frame.origin.y + self.frame.size.height, self.frame.size.width, 2.0); UIImage *gapGradient = [UIImage imageNamed:@"GapGradient"]; self.separatorHideView = [[UIImageView alloc]initWithImage:gapGradient]; self.separatorHideView.frame = seperatorRect; [self.superview addSubview:self.separatorHideView]; } 

I would also overwrite setFrame in your helper subclass of UIView to update the gapView frame if the keyboard frame changes.

+4
source

In iOS 7, you can create an inputAccessoryView to easily combine keyboard style:

 [[UIInputView alloc] initWithFrame:<#frame#> inputViewStyle:UIInputViewStyleKeyboard]; 
+6
source

All Articles