Animation only works on one button (ripple view)

会有一股神秘感。 提交于 2020-03-25 17:43:05

问题


Site used: https://material.io/develop/ios/components/ripple/

Here is my code:

import MaterialComponents.MaterialRipple

class ViewController: UIViewController {

//    let rippleView = MDCRippleView()
    let rippleTouchController = MDCRippleTouchController()

    @IBOutlet weak var playBtn: UIButton!
    @IBOutlet weak var levelsBtn: UIButton!
    @IBOutlet weak var topicsBtn: UIButton!
    @IBOutlet weak var settingsBtn: UIButton!
    @IBOutlet weak var instaBtn: UIButton!

    override func viewDidLoad() {
        super.viewDidLoad()

        //This works for instabtn (lastone)
        //        rippleTouchController.rippleView.rippleColor = .lightGray
        //        rippleTouchController.addRipple(to: playBtn)
        //        rippleTouchController.addRipple(to: levelsBtn)
        //        rippleTouchController.addRipple(to: topicsBtn)
        //        rippleTouchController.addRipple(to: settingsBtn)
        //        rippleTouchController.addRipple(to: instaBtn)

    }


    override func viewDidAppear(_ animated: Bool) {

        // Currently only works for playbtn
        rippleTouchController.rippleView.rippleColor = .lightGray
        rippleTouchController.addRipple(to: levelsBtn)
        rippleTouchController.addRipple(to: topicsBtn)
        rippleTouchController.addRipple(to: settingsBtn)
        rippleTouchController.addRipple(to: instaBtn)
        rippleTouchController.addRipple(to: playBtn)
    }
}

I've tried to put the code in viewDidAppear but it doesn't make a difference. Any thoughts?

来源:https://stackoverflow.com/questions/59721788/animation-only-works-on-one-button-ripple-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!