如何使用默认的iOS7 UIAnimation曲线
iOS7动画的行为方式与iOS6不同。它们似乎使用了不同的贝塞尔曲线。当iOS6使用一种“easeInOutSine”曲线时,iOS7更像是“easeInOutExpo”曲线。() 有没有办法利用这条曲线?我想在键盘打开/关闭时同步动画。以下是我的操作方法(至少在键盘即将显示时)如何使用默认的iOS7 UIAnimation曲线,ios,objective-c,core-animation,uianimation,Ios,Objective C,Core Animation,Uianimation,iOS7动画的行为方式与iOS6不同。它们似乎使用了不同的贝塞尔曲线。当iOS6使用一种“easeInOutSine”曲线时,iOS7更像是“easeInOutExpo”曲线。() 有没有办法利用这条曲线?我想在键盘打开/关闭时同步动画。以下是我的操作方法(至少在键盘即将显示时) -(无效)键盘将显示:(NSNotification*)通知{ NSDictionary*keyboardAnimationDetail=[notification userInfo]; UIViewAnimation
-(无效)键盘将显示:(NSNotification*)通知{
NSDictionary*keyboardAnimationDetail=[notification userInfo];
UIViewAnimationCurve animationCurve=[keyboardAnimationDetail[UIKeyboardAnimationCurveUserInfo]integerValue];
CGFloat duration=[keyboardAnimationDetail[UIKeyboardAnimationDurationUserInfoKey]floatValue];
[UIView animateWithDuration:持续时间延迟:0.0选项:(animationCurve更新,在7.1中修复。不再需要。
不管出于什么原因,键盘上报告的动画曲线是不正确的。它看起来实际上是6。这真的很聪明。在键盘显示之前,如何获得动画?只需使用(7)该选项是否有一个官方常量?它们在标题中。我认为它本身有点脆弱,因为它取决于实现。确实应该有一个框架方法来将animationCurve转换为animationOption。我应该在某个时候为它设置一个雷达。当键盘出现时,这非常适合,但为什么它不正常呢当键盘被关闭时,nc?@Abizem的语法看起来确实更好。似乎在7.0.3中得到了修复。我不认为它在7.0.3中得到了修复,但在7.1中得到了修复。
- (void)keyboardWillShow:(NSNotification *)notification {
NSDictionary *keyboardAnimationDetail = [notification userInfo];
UIViewAnimationCurve animationCurve = [keyboardAnimationDetail[UIKeyboardAnimationCurveUserInfoKey] integerValue];
CGFloat duration = [keyboardAnimationDetail[UIKeyboardAnimationDurationUserInfoKey] floatValue];
[UIView animateWithDuration:duration delay:0.0 options:(animationCurve << 16) animations:^{
// Set the new properties to be animated here
} completion:nil];
}
NSDictionary *keyboardAnimationDetail = [notification userInfo];
CGRect keyboardEndFrameWindow = [keyboardAnimationDetail[UIKeyboardFrameEndUserInfoKey] CGRectValue];
double keyboardTransitionDuration = [keyboardAnimationDetail[UIKeyboardAnimationDurationUserInfoKey] doubleValue];
// gives incorrect value of 7 on dismissal
// UIViewAnimationCurve keyboardTransitionAnimationCurve = [keyboardAnimationDetail[UIKeyboardAnimationCurveUserInfoKey] integerValue];
CGRect keyboardEndFrameView = [self.view convertRect:keyboardEndFrameWindow fromView:nil];
CGFloat newConstant = (self.view.frame.size.height - keyboardEndFrameView.origin.y);
[UIView animateWithDuration:keyboardTransitionDuration
delay:0.0f
options:newConstant == 0 ? (6 << 16) : (7 << 16)
animations:^{
self.tableView.contentInset = UIEdgeInsetsMake(self.tableView.contentInset.top, 0, self.view.frame.size.height - keyboardEndFrameView.origin.y + self.commentToolbar.frame.size.height, 0);
self.tableView.scrollIndicatorInsets = UIEdgeInsetsMake(self.tableView.scrollIndicatorInsets.top, 0, self.view.frame.size.height - keyboardEndFrameView.origin.y + self.commentToolbar.frame.size.height, 0);
self.commentViewToSuperviewBottomConstraint.constant = (self.view.frame.size.height - keyboardEndFrameView.origin.y);
[self.view layoutIfNeeded];
}
completion:^(__unused BOOL finished){
}];