mvasco
mvasco

Reputation: 5101

Background color from UIView is not changing

I am working on a iOS swift app. In a view Controller I am declaring a UIView :

@IBOutlet weak var task_color_view: UIView!

From another view controller I am getting a value for the variable color_cat:

I am checking the value for the variable and it is 9:

println ("COLOR CAT===")
println (color_cat)

Here is the console output:

COLOR CAT===
9

Then I try to change the background color from the UIView depending on the value of color_cat:

...
else if color_cat == "9" {
             self.task_color_view.backgroundColor == UIColor.cyanColor()
                                    println("ESTOY EN CAT_COLOR =9")
        }
...

The console is showing that the app detects that color_cat == "9" (then the output is shown as follows)

ESTOY EN CAT_COLOR =9

But the background color of the UIView doesn't change to cyan.

Any help is welcome. What is wrong there....

Upvotes: 0

Views: 1165

Answers (1)

keithbhunter
keithbhunter

Reputation: 12334

self.task_color_view.backgroundColor == UIColor.cyanColor()

This line has two equal signs in it; comparing equality. Change it to one equal sign so it will assign the value.

self.task_color_view.backgroundColor = UIColor.cyanColor()

Upvotes: 1

Related Questions