Hallo, i have main view conrtoller class, I would like to start the function in other UIview class.
When i make it "static func..." = there is an error - Instance member 'view' cannot be used on type 'BattleViewController'.
Thank You for help.
func setGameOverInfo() {
let gameOver = UILabel()
gameOver.text = "Game over\n" + "Your score: " + BattleViewController.updatedScore()
gameOver.numberOfLines = 2
gameOver.font = UIFont.systemFont(ofSize: 24)
gameOver.textColor = UIColor.white
gameOver.textAlignment = .center
view.addSubview(gameOver)
gameOver.translatesAutoresizingMaskIntoConstraints = false
let centerXGOConstraint = NSLayoutConstraint(item: gameOver, attribute: NSLayoutConstraint.Attribute.centerX, relatedBy: NSLayoutConstraint.Relation.equal, toItem: view, attribute: NSLayoutConstraint.Attribute.centerX, multiplier: 1, constant: 0)
let centerYGOConstraint = NSLayoutConstraint(item: gameOver, attribute: NSLayoutConstraint.Attribute.centerY, relatedBy: NSLayoutConstraint.Relation.equal, toItem: view, attribute: NSLayoutConstraint.Attribute.centerY, multiplier: 1, constant: -20 * scale)
view.addConstraints([centerXGOConstraint, centerYGOConstraint])
}