Modifying the frame of a view, or removing the view from the parent view will directly cause the view's layoutSubviews method to be called, and if the contentMode is set to UIViewContentModeRedraw, it will also cause the drawRect method to be called. At this time, if you customize these two methods to do some drawing and layout work, the CPU and GPU will be consumed to do your work.
So, if you just want to hide the view, just use the hidden attribute directly.
Under normal circumstances, it is better to use hidden, but if there are constraints that need to be changed or layoutsubview is required, it is better to remove or change the frame.
Generally hidden is more reliable because you don’t need to change the original frame. When you need to display it again, you can just modify the attributes directly. Changing the frame every time is not only slow but also modifies the original control. For constraints, if you change the frame, you don't need to re-constraint, otherwise you have to uninstall the constraint. Let’s look at each situation
Modifying the frame of a view, or removing the view from the parent view will directly cause the view's layoutSubviews method to be called, and if the contentMode is set to UIViewContentModeRedraw, it will also cause the drawRect method to be called. At this time, if you customize these two methods to do some drawing and layout work, the CPU and GPU will be consumed to do your work.
So, if you just want to hide the view, just use the hidden attribute directly.
Setting hidden is more common.
It’s the same for users, but the system’s hidden version is more reliable.
You can do this [self.xxx removeFromSuperview], it depends on the demand
hiden is better
After being hidden, he still has to occupy his position, and his related constraints also exist. It depends on the demand
If there are subviews, use hidden or removefromsuperview
Under normal circumstances, it is better to use hidden, but if there are constraints that need to be changed or layoutsubview is required, it is better to remove or change the frame.
If you want to hide, just set hidden. Otherwise, the name hidden directly translates to hidden, so there is no need to do anything~
Generally hidden is more reliable because you don’t need to change the original frame. When you need to display it again, you can just modify the attributes directly. Changing the frame every time is not only slow but also modifies the original control. For constraints, if you change the frame, you don't need to re-constraint, otherwise you have to uninstall the constraint. Let’s look at each situation