我无法处理autolayout,我需要实现类似于facebook / instagram的登录页面。也就是说,当您单击输入字段登录名或密码时,键盘和所有表示都会适应窗口的新大小。
func updateBottomLayoutConstraintWithNotification(_ notification: Notification) {
let userInfo = notification.userInfo!
let animationDuration = (userInfo[UIKeyboardAnimationDurationUserInfoKey] as! NSNumber).doubleValue
let keyboardEndFrame = (userInfo[UIKeyboardFrameEndUserInfoKey] as! NSValue).cgRectValue
let convertedKeyboardEndFrame = view.convert(keyboardEndFrame, from: view.window)
let rawAnimationCurve = (notification.userInfo![UIKeyboardAnimationCurveUserInfoKey] as! NSNumber).uint32Value << 16
let animationCurve = UIViewAnimationOptions.init(rawValue: UInt(rawAnimationCurve))
bottomLayoutConstraint.constant = (view.bounds).maxY - convertedKeyboardEndFrame.minY
UIView.animate(withDuration: animationDuration, delay: 0.0, options: animationCurve, animations: {
self.view.layoutIfNeeded()
}, completion: nil)
}
答案 0 :(得分:0)
Autolayout的提示:
static table view
或 float degree = Math.round(sensorEvent.values[0]);
tvHeading.setText(Float.toString(degree) + " degrees");
RotateAnimation ra = new RotateAnimation(
of, -degree,
Animation.RELATIVE_TO_SELF, 0.5f,
Animation.RELATIVE_TO_SELF,
0.5f);
// how long the animation will take place
ra.setDuration(210);
// set the animation after the end of the reservation status
ra.setFillAfter(true);
// Start the animation
image.startAnimation(ra);
。