【问题标题】:How to use if statement depending on UIView background color如何根据 UIView 背景颜色使用 if 语句
【发布时间】:2018-07-10 15:22:00
【问题描述】:

我正在尝试根据视图控制器的背景颜色使用if statement

if view.backgroundColor = .red {

}

这不起作用。它给了我错误:

'UIColor?' 类型的值没有成员'red'

我只想要if statement,具体取决于以编程方式设置的背景颜色。

【问题讨论】:

    标签: ios swift if-statement uiview uiviewcontroller


    【解决方案1】:

    比较时必须使用=== 是赋值运算符

    if view.backgroundColor == .red {
    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-03-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-08
      • 1970-01-01
      相关资源
      最近更新 更多