Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do you have to explicitly call setNeedsDisplay after calling setFrame on a UIView?

Tags:

ios

uiview

Do you have to explicitly call setNeedsDisplay after calling setFrame on UIView as shown in the following cases?

view1.frame = frame;
[view1 setNeedsDisplay];

[view2 setFrame:frame];
like image 724
Dmitry Avatar asked Dec 01 '25 06:12

Dmitry


1 Answers

Short answer: No

You call setNeedsDisplay when you need method drawRect to be called, and according to UIView Class Reference.-

Changing the frame rectangle automatically redisplays the receiver without invoking the drawRect: method. If you want the drawRect: method invoked when the frame rectangle changes, set the contentMode property to UIViewContentModeRedraw.

like image 90
ssantos Avatar answered Dec 03 '25 18:12

ssantos



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!