我正在使用Swift在iOS 8.4中构建一个应用程序.
我有一个包含a 和UITableView的自定义.这一切都相当直接,一切都很好.UITableViewCellUILabelUIImageView
我正在尝试创建一个类似于此演示中演示的视差效果.
我目前在我的代码中有这个代码 tableView.cellForRowAtIndexPath
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell = self.tableView.dequeueReusableCellWithIdentifier("myitem", forIndexPath: indexPath) as! MixTableViewCell
cell.img.backgroundColor = UIColor.blackColor()
cell.title.text = self.items[indexPath.row]["title"]
cell.img.image = UIImage(named: "Example.png")
// ideally it would be cool to have an extension allowing the following
// cell.img.addParallax(50) // or some other configurable offset
return cell
}
Run Code Online (Sandbox Code Playgroud)
该块存在于类似的类中 class HomeController: UIViewController, UITableViewDelegate, UITableViewDataSource { ... }
我也知道我可以通过我的班级听滚动事件func scrollViewDidScroll.
除此之外,感谢帮助!