構成に応じて上下からスライドするSlideViewアニメーションを実装しています。SlideViewアニメーションの実装SlideFromTopとSlideFromBottom
slideFromTopでは、正常に動作します。 slideFromBottomの場合、スライドビューの半分しか表示されません。ここに私のSlideViewControllerがあります。
const int VIEW_HEIGHT = 44;
-(void) slideInFromBottom
{
CGRect screenSize = [[UIScreen mainScreen] bounds];
self.view.frame = CGRectMake(0,screenSize.size.height, self.view.frame.size.width, VIEW_HEIGHT);
[UIView animateWithDuration:2.0 animations:^{
self.view.frame = CGRectMake(0, screenSize.size.height - VIEW_HEIGHT, self.view.frame.size.width,VIEW_HEIGHT);
} completion:^(BOOL finished) {
[UIView animateWithDuration:2.0 delay:2.0 options:UIViewAnimationOptionAllowAnimatedContent animations:^{
self.view.frame = CGRectMake(0, screenSize.size.height, self.view.frame.size.width, VIEW_HEIGHT);
} completion:^(BOOL finished) {
}];
}];
}
-(void) slideInFromTop
{
self.view.frame = CGRectMake(0, (-1) * VIEW_HEIGHT, self.view.frame.size.width, VIEW_HEIGHT);
CGRect temp = self.view.frame;
[UIView animateWithDuration:2.0 animations:^{
self.view.frame = CGRectMake(0, 0, self.view.frame.size.width,VIEW_HEIGHT);
} completion:^(BOOL finished) {
[UIView animateWithDuration:2.0 delay:2.0 options:UIViewAnimationOptionAllowAnimatedContent animations:^{
self.view.frame = temp;
} completion:^(BOOL finished) {
}];
}];
}
ユーザーがSlideViewControllerは、次のコードを使用して呼び出します:
-(IBAction) save:(id) sender
{
SlideViewController *slideViewController = [[SlideViewController alloc] initWithTitle:@"Customer has been saved!" animationType:SlideInFromTop];
[self.view addSubview:slideViewController.view];
}
はUPDATE 2:自分で保存
self.view.frame = CGRectMake(0, screenSize.size.height - (1.3 * VIEW_HEIGHT), self.view.frame.size.width,VIEW_HEIGHT);
ビューの半分しか表示されない場合は、y因子に2を掛ける必要があることを意味しませんか? – CodaFi
実際、それは半分以上が表示されているようですが、私の質問はなぜslideFromTopアニメーションと同様に全体を表示しないのかということです。 Update 2は、全体のビューを表示するslideFromBottomの変更を示します。 – azamsharp