ios - Swift 中的隐式成员表达式

标签 ios swift apple-radar

关于 Implicit Member Expression,我遇到了一些不一致的行为在 Swift 中:

import UIKit

let button = UIButton()
button.backgroundColor = .brownColor() # works
button.setTitleColor(.brownColor(), forState: .Normal) # doesn't work
button.setTitleColor(UIColor.brownColor(), forState: .Normal) # works

在作业中使用前导点符号时,一切都按预期工作。当使用它作为函数的参数时,swift 会抛出一个编译器错误( Playground 只是崩溃)。使情况复杂化的是,UIControlState 枚举正确地插入了隐式成员表达式值。

这是一个错误吗?

最佳答案

这是一个错误,至少在最新的 Swift 2.1 版本中已修复

关于ios - Swift 中的隐式成员表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28834354/

相关文章:

ios - 我如何在 Apple 的 Radar 中跟踪错误报告?

ios - 通过 UIAlertController 登录/注册

iOS 10 Today Extension 不会进入扩展模式,仍保持紧凑模式

ios - UITableViewController 内部 UINavigationController 和 UITabBarController 底部插入关闭

ios - 是否可以使用 iOS Facebook SDK 检索用户的_whole_好友列表?

ios - 如何停止 Swift 中的 UIView 移动?

ios - Swift Google+ 登录 GPPSignIn.sharedInstance().userID 始终等于 nil

ios - 如何在 Swift 中为 Collection View 添加边框?