According to documents I read, they always show that I should define a subview in a class. Like this :
@interface PolygonView : UIView.
I have to inherit from UIView.
Could I define a variable with UIView type in a class which inherit from NSObject? After that, I make a connection from that variable to UIView which is defined in Interface Builder.
The problem is that I can not override – (void)drawRect:(CGRect)rect
Yes, you can define a variable in a plain NSObject subclass that points to a UIView. But if you do, of course you can’t override
drawRect:— that object just has a reference to a UIView, it isn’t a view itself. It’s much like you can have a variable that’s an int, but that doesn’t mean the object containing that variable is an int.If you want to override a view’s drawing, you need to make a view. You can still have a separate class that interacts with your UIView subclass from outside.