Comment créer un effet de parallaxe dans UITableView avec UIImageView dans leurs cellules prototypes

Je suis en train de construire une application dans iOS 8.4 avec Swift.

J'ai un UITableView avec une coutume UITableViewCell qui comprend un UILabel et UIImageView. Tout ceci est assez simple et le tout rend très bien.

Je suis en train de créer un effet de parallaxe similaire à celui démontré dans cette démo.

J'ai actuellement ce code dans mon 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
}

Ce bloc existe à l'intérieur d'une classe qui ressemble à class HomeController: UIViewController, UITableViewDelegate, UITableViewDataSource { ... }

Je suis aussi conscient que je peux écouter pour faire défiler les événements dans ma classe via func scrollViewDidScroll.

Autre que cela, l'aide est apprécié!

source d'informationauteur ded