I know how to modify property of an object from another class in parent/child relationship mode, But, If is not in parent/child relationship i really can't make it, anyone can solve my problem?
First viewController:
class ViewController: UIViewController {
var uview:UIView = UIView()
override func viewDidLoad() {
super.viewDidLoad()
uview.frame = CGRectMake(55, 175, 100, 100)
uview.backgroundColor = UIColor.greenColor()
self.view.addSubview(uview)
var sec = second()
self.view.addSubview(sec.view)
}
}
Second viewController:
class second:UIViewController{
var button = UIButton()
var color = UIColor.blackColor()
override func viewDidLoad() {
super.viewDidLoad()
button.frame = CGRectMake(55, 55, 100, 100)
button.backgroundColor = UIColor.redColor()
button.addTarget(self, action: "press", forControlEvents:UIControlEvents.TouchUpInside)
self.view.addSubview(button)
}
func press(){
var first:ViewController = ViewController()
first.uview.backgroundColor = UIColor.purpleColor()
}
}