let vc = viewcontroller()
let navc = uinavigationcontroller(ROOTVIEWCONTROLLER:VC)
window = UIWindow(frame: uiscreen. Mainscreen(). Bounds)
window?. backgroundcolor = uicolor. Whitecolor()
window?. Rootviewcontroller = NAVC
window?. makekeyandvisible()
//Override point for customization after application launch.
return true
Import UIKit
Class Viewcontroller: uiviewcontroller {
override func viewdidload () {
Super. Viewdidload()
let btn = UIButton(frame: cgrectmake()
Btn. settitle(" next page ", forstate: uicontrolstate. Normal)
Btn. backgroundcolor = uicolor. Redcolor()
Btn. addTarget(self, action: "PUSHTOSECONDVC", forControlEvents: uicontrolevents . touchupinside)
View. Addsubview(BTN)
additional setup after loading the view, typically from a nib.
}
func PUSHTOSECONDVC () {
let secondvc = secondviewcontroller()
SECONDVC. closure = {
(Color:uicolor),Void
inch
self. View. BackgroundColor = Color
}
navigationcontroller?. Pushviewcontroller(SECONDVC, animated: true)
}
override func didreceivememorywarning () {
Super. Didreceivememorywarning()
//Dispose of any resources, can be recreated.
}
}
Import UIKit
Class Secondviewcontroller: uiviewcontroller {
var closure: ((color:uicolor),Void)?
override func viewdidload () {
View. BackgroundColor = uicolor. Cyancolor()
Super. Viewdidload()
let btn = UIButton(frame: cgrectmake()
Btn. settitle(" previous page ", forstate: uicontrolstate. Normal)
Btn. backgroundcolor = uicolor. Redcolor()
Btn. addTarget(self, action: "POPTOFIRSTVC", forControlEvents: uicontrolevents. touchupinside)
View. Addsubview(BTN)
additional setup after loading the view.
}
override func didreceivememorywarning () {
Super. Didreceivememorywarning()
//Dispose of any resources, can be recreated.
}
func POPTOFIRSTVC () {
let greencolor = uicolor. Greencolor()
Closure! ( Color:greencolor)
navigationcontroller?. popviewcontrolleranimated(true)
}
/*
MARK:-Navigation
In a storyboard-based application, you'll often want to do a little preparation before navigation
Override Func Prepareforsegue (Segue:uistoryboardsegue, sender:anyobject?) {
Get The new view controller using Segue.destinationviewcontroller.
Pass the selected object to the new view controller.
}
*/
}
IOS closure Pass-through and proxy-pass values