我正在尝试为UICollectioView单元创建材质涟漪效应。对于Android来说,有几个材质设计选项可以这样做,但对于看起来并非如此的iOS。下面是我使用的原型来填充UICollectioView我的自定义单元格:UICollectionView单元的材质纹波效应
import UIKit
class PollCell: UICollectionViewCell {
@IBOutlet weak var imageView: UIImageView!
@IBOutlet weak var pollQuestion: UILabel!
}
我在哪里初始化CollectioViewCell:
override func viewDidLoad() {
super.viewDidLoad()
ref = FIRDatabase.database().reference()
prepareMenuButton()
// Uncomment the following line to preserve selection between presentations
// self.clearsSelectionOnViewWillAppear = false
// Register cell classes
self.dataSource = self.collectionView?.bind(to: self.ref.child("Polls")) { collectionView, indexPath, snap in
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath) as! PollCell
//Here is where I am having issues
cell.pulseAnimation
/* populate cell */
cell.pollQuestion.text = snap.childSnapshot(forPath: "question").value as! String?
let urlPollImage = snap.childSnapshot(forPath: "image_URL").value as! String?
cell.imageView.sd_setImage(with: URL(string: urlPollImage!), placeholderImage: UIImage(named: "Fan_Polls_Logo.png"))
//Comment
return cell
}
这里是一个设备上的一个细胞的图像:
我已经更新的材料 - 你能指出我应该如何纠正我的代码?感谢帮助。 – tccpg288
'PollCell'应该继承Material的'CollectionViewCell',它默认启用脉冲动画。这里是一个示例项目,[CollectionView](https://github.com/CosmicMind/Samples/tree/master/Projects/Programmatic/CollectionView/CollectionView),以帮助您顺利完成任务。 – CosmicMind
我得到它的工作,非常感谢!现在我只是难以使单元格点击.... – tccpg288