I created a User Defined Runtime Attributes to my custom UIView in IB, and the interesting thing is, that I can access it in touchesBegan:withEvent: method but not in initWithCoder: Do you know why?

If you need to access the values when setting up your view instead of processing it in initWithCode: use awakeFromNib
It is because the views from IB are finished loading after initWithCoder. The following will help you understand the process. It is explained for UIViewControllers, but the concept is the same (from the ViewController Programming Guide):
When you create a view controller in a storyboard, the attributes you configure in Interface Builder are serialized into an archive. Later, when the view controller is instantiated, this archive is loaded into memory and processed. The result is a set of objects whose attributes match those you set in Interface Builder. The archive is loaded by calling the view controller’s initWithCoder: method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With