mikelily

error scroll

Jun 13th, 2019
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 1.63 KB | None | 0 0
  1. for index in 0..<catalogs.count {
  2.             print("\(index).\(catalogs[index].name)")
  3.             let catalogScrollView = UIScrollView()
  4.             let catalogContainerView = UIView()
  5.            
  6.            
  7.             catalogScrollView.showsHorizontalScrollIndicator = false
  8.             catalogScrollView.showsVerticalScrollIndicator = false
  9.            
  10.             catalogScrollView.bounces = false      // 滑動超過單張圖範圍時是否使用彈回效果
  11.             catalogScrollView.delegate = self
  12.             // TODO: For test color
  13.             catalogScrollView.backgroundColor = .gray
  14.             self.scrollView.addSubview(catalogScrollView)
  15.            
  16.             catalogScrollView.snp.makeConstraints { (makes) in
  17.                 makes.left.right.equalToSuperview()
  18.                 if index == 0 {
  19.                     makes.top.equalTo(self.pageScrollView.snp.bottom).offset(10)
  20.                 }else{
  21.                     makes.top.equalTo(self.pageScrollView.snp.bottom).offset( CGFloat(10*(index+1)) + fullScreenSize.width/16*9*CGFloat(index))
  22.                 }
  23.                    
  24.                 if index == catalogs.count{
  25.                     print("set bottom")
  26.                     makes.bottom.equalToSuperview().offset(-10)
  27.                 }
  28.                 makes.height.equalTo(fullScreenSize.width/16*9)
  29.             }
  30.            
  31.             catalogScrollView.addSubview(catalogContainerView)
  32.             catalogContainerView.snp.makeConstraints { (makes) in
  33.                 makes.edges.equalToSuperview()
  34.                 makes.height.equalTo(fullScreenSize.width/16*9)
  35.             }
  36.         }
Advertisement
Add Comment
Please, Sign In to add comment