I have a UIView
subclass that I am doing some custom drawing in. When drawRect:(CGRect)rect
is getting called rect.size
is either (64, 63) or (63, 64); self.frame.size
is (64, 64).
I have multiple instances of this subclass, most of which get the expected (64, 64) size for the drawRect
parameter.
What are conditions that may cause some of these subclasses to have modified drawRect
bounds but not others?
Additional tidbits:
rect.size
on subesquent calls to drawRect
The rect passed to drawRect is the rect that the system is asking you to draw (dirtyRect) in your view's coordinate system.
It can be self.bounds, or it can be a different rect.
Generally, you should simply ignore the parameter and draw yourself in self.bounds, unless your drawing is very complex. Paying attention to the dirtyRect parameter passed in is an optimisation which should be ignored until you've profiled your app and determined it is a hot spot.
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