mercredi 19 avril 2017

Changing a Views textLabel from a different View

I have a custom class called colorChangerViewClass that inherits from UIView:

class colorChangerViewClass: UIView {


@IBOutlet weak var controller: ViewController!

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
    // I want to change a textLabel in the main ViewController based on the current finger position here!
    }

override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
    // And here aswell!
}

override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) { ... }


func setColor(color: UIColor) {
    self.backgroundColor = color
}

}

Inside the touchesBegan and touchesMoved methods I want to change a textLabel in the main ViewController (a different one) based on the current finger position.

What is the best way to establish communication between the two classes colorChangerViewClass and ViewController?






Comments
0 Comments

0 commentaires:

Enregistrer un commentaire