ios - How to add UIButton Programmatically from a NSObject Class -


i trying create uibutton in nsobject class. error " use of unresolved identifier view. figured needs have uiviewcontroller work.

is there work around create multiple buttons on multiple view controllers. missing?

func createbutton () {     let button = uibutton();     button.settitle("add", forstate: .normal)     button.settitlecolor(uicolor.bluecolor(), forstate: .normal)     button.frame = cgrectmake(15, -50, 200, 100)     view.addsubview(button) } 

declare method definition parameter-argument in want add button :

func createbutton (view:uiview) {     let button = uibutton();     button.settitle("add", forstate: .normal)     button.settitlecolor(uicolor.bluecolor(), forstate: .normal)     button.frame = cgrectmake(15, -50, 200, 100)     view.addsubview(button) } 

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -