Search code examples
iosobjective-cuikeyboardios-keyboard-extension

iOS custom keyboard template background colour as image


I want to change the custom keyboard template background colour.The default colour is grey. am trying to supply an image for its background but it is still showing grey.Below is the code I tried

     self.view.opaque = YES;
     self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"bg"]];

But the same background colour changes when I did like below code

   self.view.opaque = YES;
   self.view.backgroundColor = [UIColor blackColor];

And similarly the same issue when I pass UIImages to UIButton's current image inside the keyboard template.Where am I going wrong?


Solution

  • I will answer my own question.Found the answer here.Thanks to honcheng.

    You probably didn't add the image to your keyboard target. Check your keyboard target > Build Phases > Copy bundle resources to make sure that the image is there. Drag it there if it isn't.Note that I am talking about the keyboard target, not the host app. That could be the confusion here.