且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将按钮 (UIView) 绑定到在多个文本字段中工作的键盘 (Swift 4.2)

更新时间:2022-01-08 03:04:30

在这个动画中,如果使用frame来控制按钮的位置,按钮应该是在垂直方向上不受约束的.

In this animation, if you use frame to control the position of button, the button is supposed to be free of constrains in vertical direction.

    UIView.animateKeyframes(withDuration: duration, delay: 0.0, options: UIView.KeyframeAnimationOptions(rawValue: curve), animations: {
    self.frame.origin.y += deltaY
}, completion: nil)

从 UIButton 移除所有约束后,我很好地使用了这个动画.否则,self.frame.origin.y += deltaY 应替换为约束常量.

I use this animation well after removing all the constraints from UIButton. Otherwise, self.frame.origin.y += deltaY should be replaced with constraint constant.

幸运的是移动按钮.