Contextual member has no associated value in Swift

2019-03-02 11:35发布

While translating code

$0.backgroundColor = .redColor()

Into Swift 3 I'm receiving this error:

/Users//Documents/projects//MyCell.swift:52:35: Contextual member 'redColor' has no associated value

How can I translate this code manually?

1条回答
仙女界的扛把子
2楼-- · 2019-03-02 12:24

In Swift 3 .redColor() is changed to just .red.

 $0.backgroundColor = .red

For more detail about this read Apple Documentation on UIColor under Symbols section check Type Properties.

查看更多
登录 后发表回答