Swift不支持对同一个类的同一种方法进行重复定义,对UIView进行扩展,分别写了两个extension,就会出现如上图所示 Invalid redeclaration of '' 红色的错误,查看自己的代码是否有重复的删除即可。
extension UIView {
var viewFrome_left :CGFloat {
get {
return self.frame.origin.x
}
set {
var frame = self.frame
frame.origin.x = newValue
self.frame = frame
}
}
}
// 重复设置方法
extension UIView {
var viewFrome_left :CGFloat {
get {
return self.frame.origin.x
}
set {
var frame = self.frame
frame.origin.x = newValue
self.frame = frame
}
}
}