我刚刚将我的swift 2.3代码转换为3.0代码,但当我尝试更改字体类型时,突然UILabel视图显示一个错误。这就是错误。它显示(name: String, size: CGFloat)-> UIFont is not convertible to (name: String, size: CGFloat)-> UIFont?为什么我不能改变字体类型?我已经清理并构建了项目,但显示了相同的错误。这是UILabel
let placeholder = UILabel()
placeholder.bounds = self.tableView.bounds
placeholder.textAlignment = .Center
placeholder.textColor = UIColor(red: 230.0/255.0, green: 230.0/255.0, blue: 230.0/255.0, alpha: 1.0)
placeholder.font = UIFont(name: "Avenir-Light", size: 15.0)
placeholder.text = "No Events"
self.tableView.backgroundView = placeholder下面是错误

发布于 2016-09-21 17:31:43
placeholder.font = UIFont(name: "Avenir-Light", size: 15.0)你应该试着这样写:
placeholder.font = UIFont.init(name: "Avenir-Light", size: 15)有关更多信息,请参阅this
https://stackoverflow.com/questions/39612603
复制相似问题