I have some custom views, that conforms to a protocol:
class CustomView1: UIView, MyProtocol {
...
}
class CustomView2: UIView, MyProtocol {
...
}
Then later, I want to check a view is my custom view or not by check if view conforms to my protocol, but it's not work:
let v = view.viewWithTag(1000)
if let _ = v as? MyProtocol {
print("this is my custom view")
}
if v.self is MyProtocol.Type {
print("this is my custom view")
}
Any ideas?
Thanks!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.