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:
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.
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.
Comments
Post a Comment