简体   繁体   English

UIView的背景色未更改

[英]Background color from UIView is not changing

I am working on a iOS swift app. 我正在开发iOS swift应用。 In a view Controller I am declaring a UIView : 在视图控制器中,我声明了一个UIView:

@IBOutlet weak var task_color_view: UIView!

From another view controller I am getting a value for the variable color_cat: 从另一个视图控制器,我正在获取变量color_cat的值:

I am checking the value for the variable and it is 9: 我正在检查变量的值,它是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: 然后,我尝试根据color_cat的值更改UIView的背景颜色:

...
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) 控制台显示该应用程序检测到color_cat ==“ 9”(然后输出如下所示)

ESTOY EN CAT_COLOR =9

But the background color of the UIView doesn't change to cyan. 但是,UIView的背景色不会更改为青色。

Any help is welcome. 欢迎任何帮助。 What is wrong there.... 那里怎么了...

self.task_color_view.backgroundColor == UIColor.cyanColor() 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() self.task_color_view.backgroundColor = UIColor.cyanColor()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM