I have a UIView that contains a row of subclasses of UIView
. The subclass has overridden drawRect
: and has set contentMode = UIViewContentModeRedraw
.
As the user squashes and stretches the parent container the child views
squash and stretch. As the shape change occurs I would like to have drawRect
called repeatedly to change the contents of the child views
. So far I have been unsuccessful. What is the correct way to do this?
Cheers,
Doug
In Cocoa, you rarely (if ever) call drawRect - you just mark the region or view as needing update, and it will be scheduled for redrawing. This allows redraws for multiple invalidations to be collapsed together.
For Cocoa Touch, you want either [view setNeedsDisplay], or setNeedsDisplayinRect:(CGRect)
You need to call [view setNeedsLayout], this should cause the subviews to receive a drawRect: call if the layout changes. I haven't tested this, however.
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