Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it a good practice to setNeedsLayout/setNeedsDisplay from CALayer's methods?

My layer has a couple of dynamic properties that affect layout and/or display of the layer itself. Is it okay if I send setNeedsLayout/setNeedsDisplay from the setters of the properties or the caller of the setter is responsible for that?

like image 580
Kentzo Avatar asked Apr 27 '26 21:04

Kentzo


1 Answers

It's fine to call setNeedsLayout or setNeedsDisplay from the setters inside your UIView subclass. They return immediately and call layoutSubviews only once in the next drawing cycle.

like image 145
Troy Avatar answered May 04 '26 07:05

Troy



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!