Guest User

Untitled

a guest
Jun 20th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1. ### 佐藤さん(@hatakenokakashi) High Performance Auto Layout
  2.  
  3. High Performance Auto Layoutというセッションを振り返ります。
  4. MAMORIO株式会社でiOSエンジニアをしています。
  5. High Performance Auto LayoutはiOS12でAutoLayoutのパフォーマンスが上がったことが紹介されている。
  6.  
  7. #### Independent Sibling Views
  8. 兄弟関係の、View間で関係のないView同士の描画パフォーマンスが改善された。
  9.  
  10. #### Dependent Sibling Views・Nested Veiws
  11. 相互に関係のある兄弟関係のView同士・ネストしたViewの描画が指数関数的にパフォーマンスが落ちるのが線形に
  12.  
  13. #### Performance Improvements in iOS12
  14. Long Roe, Deep Hierarchy, Collection View, MovingTree, Hieralcy Remove
  15.  
  16. アップデートするだけでパフォーマンスが上がる。
  17.  
  18. #### Constraintのつけ外しはパフォーマンスが下がるので避けるべき。
  19. updateConstraints
  20. で deactivateしたり、removeAll()で消して新しくつけなおしたりとか。
  21. 成約を外してもう一度つけ直すとパフォーマンスが下がる。
  22.  
  23. updateConstraints() {
  24. if self.constraints == nil {
  25. // 制約をつける
  26. }
  27. }
  28.  
  29. このようにするとパフォーマンスが上がる。
  30.  
  31. #### The Render Loop
  32.  
  33. UpdateConstraintは一番末端の子Viewから制約を決めて親へたどっていく
  34. レイアウトするときは親からレイアウトされて、ディスプレイするときは親から表示される。
  35.  
  36. #### Activating constraint - Internal Structure
  37. レイアウトするときのエンジンがあって、そこが各ビューのサイズや位置を計算する。
  38. Unknowns layout must calculate
  39. minX minY width, heightが設定されているとき
  40. text2.minX = text1.minX + text1.width + 20
  41. こういう計算をさせるとパフォーマンスが下がる。
  42. ConstraintをRemoveしたりするとこの計算が再度行われることになる。
  43.  
  44. #### Building Efficient Layout より効果的なレイアウト
  45. Instruments に Auto Layout のパフォーマンスの測定が追加された。
  46. どういう制約が設定されて時間がかかったか確認する事ができる。
  47.  
  48. #### Building More Performance Layout
  49.  
  50. Cell上に猫の画像がある場合ない場合
  51. Constraintを付け替えたりするとパフォーマンスが落ちる。
  52. Imageがアルバイトない場合のどちらにもConstraintをつけておく。
  53.  
  54. #### まとめ
  55.  
  56. - (すべての)制約を外すことを避ける’
  57. - 一度だけ静的な制約をつける
  58. - 必要なときだけ制約を変更する
  59. - Viewを非表示に、不用意にRemoveしない
Add Comment
Please, Sign In to add comment