出于某种原因,我希望将UIView
个实例用作UILayoutSupport
。
UILayoutSupport
protocol defenition:
protocol UILayoutSupport: NSObjectProtocol {
var length: CGFloat { get } //Required
var bottomAnchor: NSLayoutYAxisAnchor { get } //Required
var heightAnchor: NSLayoutDimension { get } //Required
var topAnchor: NSLayoutYAxisAnchor { get } //Required
}
UIView class已经符合NSObjectProtocol
,并且已经使用相同的方式声明了属性bottomAnchor
,heightAnchor
,topAnchor
。所以,问题是:为什么使用此扩展名
extension UIView: UILayoutSupport {
var lenght: CGFloat {
return bounds.size.height
}
}
我仍然有错误
键入' UIView'不符合协议' UILayoutSupport'
答案 0 :(得分:2)
你交换了最后两个属性字母:leng ht 而不是leng th