TableView contentoffset与单元格的比率

时间:2016-12-21 04:58:38

标签: swift uitableview uiscrollview swift3

我在每个单元格上有一个滚动视图的表格视图。我必须在表格滚动上设置单元格滚动视图偏移量。我们如何使用单元格对tableconentent偏移量进行排序请帮助我在iOS中更新。我正在使用JbParralax

func scrollViewDidScroll(_ scrollView: UIScrollView) {

  let indexpath =  table.indexPathsForVisibleRows

  let a : Int = (indexpath?.count)! - 1

  for i in 0...a {
    let  b = indexpath?[i]
    let cell = table.cellForRow(at: b!) as? Custum
    cell?.myScrollView.contentOffset.y = table.contentOffset.y
  }

}

extension ViewController : UITableViewDelegate,UITableViewDataSource{
  func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return 6
  }

  func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let identifier = "Custum"
    var cell: Custum! = tableView.dequeueReusableCell(withIdentifier: identifier) as? Custum
    if cell == nil {
      var nib:Array = Bundle.main.loadNibNamed("Custum", owner: self, options: nil)!

      cell = nib[0] as? Custum
    }

    //cell.myScroll
    cell.myImage.image = UIImage(named:banner[indexPath.row])
    return cell
  } 
}

0 个答案:

没有答案