我正在嘗試爲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