【发布时间】:2014-10-04 00:52:59
【问题描述】:
我在 swift 中有一段丑陋(但有效)的解包代码:
var color = UIColor.whiteColor()
if ( label.backgroundColor? != nil )
{
color = label.backgroundColor!
}
有没有更简洁的方法可以像我在 C++ 中那样用 swift 编写?
UIColor color = (label.backgroundColor==nil) ?
UIColor.whiteColor() : label.backgroundColor;
【问题讨论】: