Ios UIButton边界动画问题

Ios UIButton边界动画问题,ios,autolayout,cabasicanimation,Ios,Autolayout,Cabasicanimation,我正在使用CABasicAnimation设置按钮边界的动画。我没有为按钮添加任何自动布局约束。这是我的密码: class ViewController: UIViewController { @IBOutlet var button: UIButton! @IBAction func onClick(sender: AnyObject) { //self.button.translatesAutoresizingMaskIntoConstraints =

我正在使用CABasicAnimation设置按钮边界的动画。我没有为按钮添加任何自动布局约束。这是我的密码:

class ViewController: UIViewController {

    @IBOutlet var button: UIButton!

    @IBAction func onClick(sender: AnyObject) {

        //self.button.translatesAutoresizingMaskIntoConstraints = true

        let animation = CABasicAnimation(keyPath: "bounds")
        animation.toValue = NSValue(CGRect : CGRect(origin: CGPointZero, size: CGSizeMake(self.button.bounds.size.height, self.button.bounds.size.height)))
        animation.delegate = self
        self.button.layer.addAnimation(animation, forKey: "")

    }

    override func animationDidStop(anim: CAAnimation, finished flag: Bool) {

        self.button.setTitle("", forState: .Normal)
        self.button.bounds = CGRect(origin: CGPointZero, size: CGSizeMake(self.button.bounds.size.height, self.button.bounds.size.height))
    }

}
如果我注释掉setTitle(“,forState:.Normal),一切正常。但是,如果使用setTitle(“,forState:.Normal),则按钮将立即返回到其原始大小。我认为这是因为自动布局生效。因此,我将translatesAutoresizingMaskIntoConstraints设置为true。我想怎么用就怎么用。但我的控制台中出现了“无法同时满足约束”错误

如何处理这个问题?我不想在我的项目中禁用自动布局。虽然我使用UIButton进行测试,但对于普通UIView也是一样的