2017-01-22 1 views
0

スワイプ3のtvOSプロジェクトのmy tableview用にこのコードを持っています。どうすれば説明できますか?スクロールセルがuitableのときにフォーカスと色を変更

この私のコードあなたのテーブルビューのデリゲートで

func numberOfSections(in tableView: UITableView) -> Int { 
 
    return 1 
 
} 
 
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 
 
    return tvChannelsArray.count 
 
} 
 
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 
 
    let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) 
 
    
 
    // Show TV Channels names 
 
    cell.textLabel?.text = ((tvChannelsArray[(indexPath as NSIndexPath).row] as AnyObject).object(forKey: "channel") as! String) 
 
    
 
    cell.imageView?.image = UIImage(named: "\(cell.textLabel!.text!)") 
 
    
 
return cell 
 
} 
 
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { 
 
    channelsTableView.isHidden = false; 
 

 
    return 100 
 
    
 
}

答えて

0

UISsrollViewDelegateメソッドを実装ScrollViewDidScroll

func scrollViewDidScroll(_ scrollView: UIScrollView) { 
     for cell in tableView.visibleCells { 
      if let currentCellPath = tableView.indexPath(for: cell), 
       let selectedCellPath = tableView.indexPathForSelectedRow { 
       guard currentCellPath != selectedCellPath else { 
        continue 
       } 
      } 
      let red = Float(cell.frame.origin.y/scrollView.contentSize.height) 
      cell.contentView.backgroundColor = UIColor(colorLiteralRed: red, green: 0.5, blue: 0.25, alpha: 1) 
     } 
    } 
+0

のtableViewは、それをどのように変化するかを見られないと言いますか? – user1178728

関連する問題