Failed to set (cornerRadius) user defined inspected property on (UIView)
The code is correct.
When you declare a @ IBDesignable
all the @IBInspectable
properties are exposed to the Interface Builder as User Defined Runtime Attributes.
The problem -
Unknown class MyClass in Interface Builder file
Is means that Interface Builder couldn't find some class. You have set wrong class that doesn't exist in your app.
Your customView class is MyView
but in the Interface Builder you have MyClass
Solution to fix-
- Set correct class in interface Builder, in your case
MyView
- Check Designable status. It should be Up to date , if it's not than something is wrong.
Also If you decided to remove customer Designable you should
- Remove custom class
- Remove User Defined Runtime Attributes
Based on the question title, a few people may come here with a slightly different problem (like I did). If you
- added an @IBInspectible
- and then deleted it in code
Then you may also get an error similar to
Failed to set (xxx) user defined inspected property on [Your Custom View] ...: this class is not key value coding-compliant for the key [xxx].
The solution is to delete the the old property.
Open the Identity inspector for your class, select the property name under User Defined Runtime Attributes, and press the minus button (-).
Again, this is not the answer to the OP's question, but it might be the answer to someone else's problem who comes here.
in Indentity inspector add in user Defined runtime attributes
layer.cornerRadius
- type string
after go to Attibutes inspector and select "Clip Subviews"