ios - Swift - Custom UIView -



ios - Swift - Custom UIView -

i can't create custom uiview within view controller. want 4 buttons (undo, dislike, like, info) in vertical side. undo , info button not appeared within view controller.

let choosepersonbuttonhorizontalpadding:cgfloat = 40.0 allow choosepersonbuttonverticalpadding:cgfloat = 20.0 func constructundobutton() -> void{ allow button:uibutton = uibutton.buttonwithtype(uibuttontype.system) uibutton allow image:uiimage = uiimage(named:"undo")! button.frame = cgrectmake(choosepersonbuttonhorizontalpadding, cgrectgetmaxy(self.backcardview.frame) + choosepersonbuttonverticalpadding, image.size.width, image.size.height) button.setimage(image, forstate: uicontrolstate.normal) self.view.addsubview(button) } func constructnopebutton() -> void{ allow button:uibutton = uibutton.buttonwithtype(uibuttontype.system) uibutton allow image:uiimage = uiimage(named:"nope")! button.frame = cgrectmake(choosepersonbuttonhorizontalpadding, cgrectgetmaxy(self.backcardview.frame) + choosepersonbuttonverticalpadding, image.size.width, image.size.height) button.setimage(image, forstate: uicontrolstate.normal) self.view.addsubview(button) } func constructlikedbutton() -> void{ allow button:uibutton = uibutton.buttonwithtype(uibuttontype.system) uibutton allow image:uiimage = uiimage(named:"liked")! button.frame = cgrectmake(cgrectgetmaxx(self.view.frame) - image.size.width - choosepersonbuttonhorizontalpadding, cgrectgetmaxy(self.backcardview.frame) + choosepersonbuttonverticalpadding, image.size.width, image.size.height) button.setimage(image, forstate:uicontrolstate.normal) self.view.addsubview(button) } func constructinfobutton() -> void{ allow button:uibutton = uibutton.buttonwithtype(uibuttontype.system) uibutton allow image:uiimage = uiimage(named:"info")! button.frame = cgrectmake(cgrectgetmaxx(self.view.frame) - image.size.width - choosepersonbuttonhorizontalpadding, cgrectgetmaxy(self.backcardview.frame) + choosepersonbuttonverticalpadding, image.size.width, image.size.height) button.setimage(image, forstate:uicontrolstate.normal) self.view.addsubview(button) }

result (ignore image , button colour part)

what want.

please advice. give thanks you.

your undo button , nope button in same frame overlapped.

func constructnopebutton() -> void{ allow button:uibutton = uibutton.buttonwithtype(uibuttontype.system) uibutton allow image:uiimage = uiimage(named:"nope")! button.frame = cgrectmake(choosepersonbuttonhorizontalpadding +undobutton.frame.size.width + undobutton.frame.origin.x, cgrectgetmaxy(self.backcardview.frame) + choosepersonbuttonverticalpadding, image.size.width, image.size.height) button.setimage(image, forstate: uicontrolstate.normal) self.view.addsubview(button) }

you might utilize code arrange sec view. there ways create better.

ios swift uiview

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -