UICollectionView 单元格的材质波纹效果 [英] Material Ripple Effect for UICollectionView Cell

查看:32
本文介绍了UICollectionView 单元格的材质波纹效果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为 UICollectioView 单元创建材质波纹效果.对于 Android,有几种材料设计选项可以这样做,但对于 iOS,情况似乎并非如此.下面是我用作原型来填充 UICollectioView 的自定义单元格:

I am trying to create a material ripple effect for a UICollectioView cell. For Android, there are several material design options to do so, but for iOS that does not appear to be the case. Below is my custom cell I am using as the prototype to populate the UICollectioView:

import UIKit

class PollCell: UICollectionViewCell {


    @IBOutlet weak var imageView: UIImageView!

    @IBOutlet weak var pollQuestion: UILabel!

}

我在哪里初始化 CollectioViewCell:

Where I initialize the 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
    }

这是设备上一个单元格的图像:

Here is an image of one of the cells on a device:

推荐答案

如果你使用 Material 的话有一个内置脉冲动画的 CollectionViewCell.您可以使用 pulseAnimation 属性设置它.希望这可以帮助.

If you use Material it has a CollectionViewCell that has the pulse animation built in. You can set it with the pulseAnimation property. Hope this helps.

这篇关于UICollectionView 单元格的材质波纹效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆