大家讲道理2017-04-17 17:42:45
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.
迷茫2017-04-17 17:42:45
It’s the same for users, but the system’s hidden version is more reliable.
黄舟2017-04-17 17:42:45
You can do this [self.xxx removeFromSuperview], it depends on the demand
阿神2017-04-17 17:42:45
After being hidden, he still has to occupy his position, and his related constraints also exist. It depends on the demand
天蓬老师2017-04-17 17:42:45
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.
天蓬老师2017-04-17 17:42:45
If you want to hide, just set hidden. Otherwise, the name hidden directly translates to hidden, so there is no need to do anything~
伊谢尔伦2017-04-17 17:42:45
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