UIView layoutSubviews delegation

I am looking for support for delegating responsibility of layoutSubviews responsibility to UIView. This will avoid the need to create a specific subclass only to implement the layoutSubviews method. I suspect the reason I found that I want this alternative, perhaps because I missed some fundamental design considerations for UIKit or? Or should I just go and make my own subclass of UIView with support for this type of layout delegation?

+3
source share
1 answer

You will want to create a subclass whenever you need a custom layout, there is no way to delegate it. This is also the only reasonable way to do this: if you contain a set of views in the supervisor, this view should control its layout routine for ease of maintenance.

You also don’t need to do the layout of the view in layoutSubviews - you can just create a layout when creating a supervisor and assign positions and sizes at this point if you do not need something reusable.

0
source

Source: https://habr.com/ru/post/1748822/


All Articles