i wondering if possible make uibutton input text text box when pressed
override func viewdidload() { super.viewdidload() var textbox = uitextfield(frame: cgrectmake(x, y, w, h)) textbox.borderstyle = uitextborderstyle.line self.view.addsubview(textbox) var button = uibutton(frame: cgrectmake(x, y, w, h)) button.backgroundcolor = uicolor.bluecolor() self.view.addsubview(button) }
is there way make var button input text text box (var textbox)
in selector method added button using addtarget
var textbox = uitextfield! var button = uibutton! override func viewdidload() { super.viewdidload() textbox = uitextfield(frame: cgrectmake(x, y, w, h)) textbox.borderstyle = uitextborderstyle.line self.view.addsubview(textbox) button = uibutton(frame: cgrectmake(x, y, w, h)) button.backgroundcolor = uicolor.bluecolor() button.addtarget(self, action:#selector(buttontapped), forcontrolevents: uicontrolevents.touchupinside) self.view.addsubview(button) } func buttontapped(object:anyobject) { textbox?.text = "your text" }
Comments
Post a Comment