prev
This article is the 15th day article of iOS Advent Calendar 2020. Yesterday, @zwtin said You should stop getting images with the thumbnail method of ALAsset.
disclaimer
There is no intention to recommend manual calculation, it is the content measured under special circumstances
--Lay out a UIScrollView with a contentView that is about 10 times the height of the screen --Case with a large number of views, such as calendar dates each consisting of UILabel
――The reason for the change is that it takes time to transition the screen. --As the title suggests, the code laid out with AutoLayout + UIStackView now calculates the frame on its own.
--The process that used to take 1.0038 seconds before the change is now 0.1084 seconds.
--Measure the time from immediately after super.loadView ()
to immediately after super.viewDidLayoutSubviews ()
――The average value of each executed 5 times alternately
--The measurement environment is iPhone 12 Pro Max
-(Originally, it was verified with iPhone 11 Pro, so it's a secret that "that? AutoLayout is relatively fast?")
――The solver of AutoLayout is excellent, and the difference update when a little change is made is strong, but after all, the optimization problem is solved at the first time, so if you can make a static decision, that's the impression.
before
after
--Up to 7 levels of nesting from UIScrollView to the bottom layer are now flatly placed directly under UIScrollView.
--In the first place, if you want to create a UIScrollView with such a contentSize, I think it is correct to use UICollectionView. ―― ~~ However, trying to do this kind of layout is troublesome ~~ ――If you want to display data for about 20 years, you may have to deal with it (but the specifications may evolve faster: smile :)
https://github.com/funnything/LayoutPerformanceDemo
We publish an app on the App Store that incorporates the changes covered in this article. It is an app that allows you to make a habit of training to make a more natural and attractive smile by making a smile every day. Nowadays, the tension tends to drop due to the corona virus, and I hope it helps to raise your feelings even a little. Please use it if you like ~
next
Tomorrow is an article by @yum_fishing.
Recommended Posts