我想要扩展基类(UIView),我在基类中处理该对象并返回具有正确类型的调用对象
extension UIView {
func withCleanBg() -> UIView {
self.backgroundColor = .clear
return self;
}
}例如,如果我调用let btn:UIButton = UIButton().withCleanBg(),我希望btn在调用扩展后保持UIButton,而不是获取UpCasted。
我希望它能链接函数调用,如UIButton().withCleanBg().withFillInParent()等
发布于 2021-05-26 05:04:40
返回Self作为类型:
func withCleanBg() -> Self {https://stackoverflow.com/questions/67695542
复制相似问题