UIView speed add / remove subview against hiding / showing

Say I have a full screen UIViewthat overlays the main screen when I press a button, and then disappears when this overlay image is affected. This one UIViewcan be added and removed from the current view with addSubview:and removeFromSuperview, or it can be added when the current view is initialized and then shown and hidden by accessing and setting the property hidden UIView. What is usually faster and better for performance (or are they the same)?

+4
source share
3 answers

I would put that show and hide will be faster. Another way requires creating / destroying an object and working with subviews.

More importantly, I think it’s easier to show and hide, and fighting complexity is paramount.

+2
source

I tried adding an imageView and trying the loop 1,000,000 times to hide and show in each loop and add deletion in each loop. The result is to hide and show 1 sec to make a cycle of 1,000,000. And add remove take 3s. I do it in the simulator :)

+1
source

, , , , , . , , , . " ".

, , , ? / , .

XIB ( XIB, ), , " " IBOutlets , . XIB, , . , . .

0

All Articles