[英]Redundant conformance of Object to Protocol
I have this error Redundant conformance of 'AnyView' to protocol 'Pressable'
when attempt to run the below code.尝试运行以下代码时,出现
Redundant conformance of 'AnyView' to protocol 'Pressable'
错误。 Could anyone shows the error or any other way to perform the same login with protocols.任何人都可以显示错误或使用协议执行相同登录的任何其他方式。
class AnyView: UIView, Pressable {
}
// MARK: - Pressable
protocol Pressable: UIView {
}
extension UIView: Pressable {
// touchesBegan
override open func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesBegan(touches, with: event)
scaleAnimation(value: 0.8)
}
}
You simply need to get rid to the AnyView
conformance to Pressable
, since its superclass, UIView
already conforms to Pressable
.你只需要摆脱对
AnyView
一致性,以Pressable
,因为它的超UIView
已符合Pressable
。
class AnyView: UIView {
}
// MARK: - Pressable
protocol Pressable: UIView {
}
extension UIView: Pressable {
// touchesBegan
override open func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesBegan(touches, with: event)
scaleAnimation(value: 0.8)
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.