0

I'm developing custom iOS keyboard for a language that iPhone doesn't support yet. I want to replicate default L&F as much as possible. I've found that default ios keyboard could be treated as the static image with additional image drawing when the user touches the keyboard.

I want my keyboard to consume as low resources as possible. There will be 40 buttons displayed simultaneously. What the correct approach should be? I can see the following different approaches:

  1. Draw entire keyboard to UIImage (or CGImage) at application startup (or even just store it in the application bundle) and display it in the view controller. When user touches keyboard, it adds CALayer and positions it in the right place.

  2. Use hierarchy of CALayers. Each button is treated as separate CALayer. The button is just a rounded rectangle with shadow and text in the center.

  3. Use hierarchy of UIButtons.

3-rd variant seems to be the most natural approach, but it introduces 40 UIButtons with corresponding internal structures. 1-st variant seems to me like the lightest one, but not very versatile, if I decide to change something. I don't know how much memory do CALayers consume, so I'm not sure about 2-nd variant.

Andrew
  • 15,357
  • 6
  • 66
  • 101
vbezhenar
  • 11,148
  • 9
  • 49
  • 63
  • 2.How you could add gesture touch recognizer to CGLayer?3. From my experience using buttons will increase the time till user will see typed letter in textField. – Tatiana Oct 27 '14 at 14:47
  • I have top-level inputviewcontroller which will intercept all touch events and find out positions of corresponding keys. – vbezhenar Oct 27 '14 at 15:33
  • Actually I decided to use hierarchy of custom UIViews, it works well enough. May be there's some memory overhead, but I don't think it's noticeable. I still wondering what the best approach would be, especially considering that on iPhone 4S there's observable lag when keyboard apperars. – vbezhenar Oct 27 '14 at 15:34
  • I also use in Keyboard extension the hierarchy of custom Views, for touch I use onTouchBegan, -Moved and -Ended. – Tatiana Oct 28 '14 at 08:55
  • Rather then drawing an image to replicate the default IOS keyboard why not style the buttons so they look like IOS buttons? – Foobar Jun 22 '16 at 20:21

0 Answers0