我使用cocoapods来实现动态按钮但不起作用

时间:2017-03-03 14:29:44

标签: ios xcode

import UIKit
import DynamicButton

class Viola: UIViewController
{

    @IBOutlet weak var dynamicButton: UIButton!

    let dynamicButton = DynamicButton(style: DynamicButtonStyle.hamburger)

    //var confettiView: SAConfettiView!

    override func viewDidLoad() {
        super.viewDidLoad()

        let dynamicButton                 = DynamicButton()
        dynamicButton.lineWidth           = 3
        dynamicButton.strokeColor         = .white
        dynamicButton.highlightStokeColor = .gray
        dynamicButton.style = DynamicButtonStyle.hamburger

        dynamicButton.setStyle(DynamicButtonStyle.close, animated: true)
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        //dynamicButton.style = DynamicButtonStyle.hamburger

    }
}

安装的链接是: http://cocoadocs.org/docsets/DynamicButton/3.1.0/

1 个答案:

答案 0 :(得分:0)

我没有使用过那个库,但很明显你创建了DynamicButton三次。我认为您应该首先确定使用哪个按钮。

例如,只做这件事会发生什么?

override func viewDidLoad() {
    super.viewDidLoad()

    let dynamicButton                 = DynamicButton(style: DynamicButtonStyle.hamburger)
    dynamicButton.lineWidth           = 3
    dynamicButton.strokeColor         = .white
    dynamicButton.highlightStokeColor = .gray
    self.view.addSubview(dynamicButton)
}