ios - How to use custom image as UIButton in Swift -


so working on project building 3rd party keyboard app lets user press single button , input line of text. simple. works fine, code working ect. except cannot figure out how have button represented image , not text.

as can see below, looks in interface builder , in code:

enter image description here

main code in keyboardviewcontroller.swift:

import uikit  class keyboardviewcontroller: uiinputviewcontroller {  var keyboardview: uiview!  @iboutlet var nextkeyboardbutton: uibutton!  override func updateviewconstraints() {     super.updateviewconstraints()     // add custom view sizing constraints here }  override func viewdidload() {      super.viewdidload()       self.loadinterface()  }  func loadinterface() {      var keyboardnib = uinib(nibname: "keyboardview", bundle: nil)      self.keyboardview = keyboardnib.instantiatewithowner(self, options: nil)[0] as! uiview      view.addsubview(self.keyboardview)      view.backgroundcolor = self.keyboardview.backgroundcolor      self.nextkeyboardbutton.addtarget(self, action: "advancetonextinputmode", forcontrolevents: .touchupinside)  } 

but when run app in simulator, see text button , not image had provided.

enter image description here

what going on, , can fix seemingly simple problem? i'm stumped.

i don't know how mark question duplicate, answer question here. depending on want button behave you'll have hands dirty , assign image manually using code.

uibutton: set image selected-highlighted state

create button programmatically , set background image


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -