Reputation: 327
Both ways seem to work, are there any differences in performance?
Upvotes: 0
Views: 119
Reputation: 253
Well it really depends on what you want to do. You can call it from init
but then the code will only be called when you instantiate the class. If you put it in layoutSubviews
you can have the code called multiple times by making the view redraw.
So if you need to update constraints based on things changing it could be advantageous to use layoutSubviews
but if you don't need to modify the constraints I would personally make a new method called setConstraints
which would contain all the constraints and call that from init
Upvotes: 0