我有这段代码
func generate() -> Bool {
var button = UIButton(frame: CGRectMake(CGFloat(0), CGFloat(0), 50, 50))
button.layer.backgroundColor = UIColor(red: (219/255.0), green: (225/255.0), blue: (235/255.0), alpha: 1).CGColor
self.view.addSubview(button)
UIView.animateWithDuration(2, animations: {
button.frame = CGRectMake(10, 10, 30, 40)
})
return true
}
将按钮添加到子视图后,我想将按钮浮动(动画)到另一个位置。但动画不起作用。该按钮立即放置在没有动画的位置上。