フィルタと一緒に注文できるUITableViewがあります。モーダルビューを使用する代わりに、画面の左側から来て、tableViewを部分的にカバーするビューのアニメーションを作成したかっただけです。
これが私の「フィルタービュー」をどのように見せたいかの例です:
フィルタなし:
フィルター付き:
何がトリックをすることができますか?
フィルタと一緒に注文できるUITableViewがあります。モーダルビューを使用する代わりに、画面の左側から来て、tableViewを部分的にカバーするビューのアニメーションを作成したかっただけです。
これが私の「フィルタービュー」をどのように見せたいかの例です:
フィルタなし:
フィルター付き:
何がトリックをすることができますか?
再利用可能なコードを使用した適切な方法:
アニメーションカテゴリをに追加UIView
@interface UIView (MyAnimation)
-(void)slideInWithDuration:(NSTimeInterval)duration;
//implementation
-(void)slideInWithDuration:(NSTimeInterval)duration
{
CGRect screenRect = [[UIScreen mainScreen] bounds];
float nSpace = 0.0f //put any value you think right
CGFloat extraOffset = self.view.frame.size.width / 2 + nSpace;
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position"];
animation.fromValue = [NSValue valueWithCGPoint:CGPointMake(screenRect.origin.x - extraOffset, self.view.center.y)];
animation.toValue = [NSValue valueWithCGPoint:self.view.center];
animation.duration = duration;
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
[self.layer addAnimation:animation forKey:@"SlideInAnimation"];
}
のSomeWhereViewController.m
UIWindow *mainWindow = [[UIApplication sharedApplication] keyWindow];
UIView *someView = [[UIView alloc] init];
someView.frame = // customize to your like
[mainWindow addSubview:someView];
[someView slideInWithDuration:0.7];
お役に立てば幸いです。
1つの方法は、ビューが現在のビューの外側になるようにフレームを設定してこの新しいビューを追加し、アニメーションブロックを使用してフレームを現在の位置にアニメーション化することです。この新しいビューをに追加する必要がありますself.navigationController.view
。
例:-
newView.frame = frameOutsideCurrentView;
[UIView animateWithDuration:0.5
delay:1.0
options:UIViewAnimationCurveEaseOut
animations:^{
newView.frame = currentFrame;
}
completion:^(BOOL finished){
}];
オーバーレイビューをaでラップし、プロパティをまたはUIWindow
に設定します。windowLevel
UIWindowLevelAlert
UIWindowLevelStatusBar