以不同角度转换每个可见单元格

时间:2015-11-30 13:35:43

标签: ios swift nsindexpath

我想在我的集合视图中转换不同角度的每个可见单元格,我试图使用索引来做但结果非常随机,当我滚动它搞砸了

override func scrollViewWillEndDragging(scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
var identy = CATransform3DIdentity
identy.m34 = -1/200

let arrayOfAngles = [-0.4, -0.2, 2, 4]
//    for index in currentIndexPath {
for (index, cell) in collectionView!.visibleCells().enumerate() {
  let angle:CGFloat!
  print(index)
  switch(index) {
  case 0: angle = 0.2
  case 1: angle = 0.1
  case 2: angle = -0.1
  case 3: angle = 0.4
  case 4: angle = 0.4
  case 5: angle = 0.4
  case 6: angle = -0.4
  case 7: angle = 0.2
  case 8: angle = 0.0
  case 9: angle = 0.0
  case 10: angle = -0.2
  case 11: angle = -0.3
  default: angle = 10
  }

  UIView.animateWithDuration(0.5, delay: 0.0, options: [], animations: { () -> Void in
    cell.layer.transform = CATransform3DRotate(identy, angle,  5,  90,  0 )
    }, completion: nil)
}




}

0 个答案:

没有答案