0

フィルタと一緒に注文できるUITableViewがあります。モーダルビューを使用する代わりに、画面の左側から来て、tableViewを部分的にカバーするビューのアニメーションを作成したかっただけです。

これが私の「フィルタービュー」をどのように見せたいかの例です:

フィルタなし:

フィルタなし

フィルター付き:

フィルター付き

何がトリックをすることができますか?

4

3 に答える 3

2

再利用可能なコードを使用した適切な方法:

アニメーションカテゴリをに追加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];

お役に立てば幸いです。

于 2013-02-21T05:14:48.283 に答える
1

1つの方法は、ビューが現在のビューの外側になるようにフレームを設定してこの新しいビューを追加し、アニメーションブロックを使用してフレームを現在の位置にアニメーション化することです。この新しいビューをに追加する必要がありますself.navigationController.view

例:-

newView.frame = frameOutsideCurrentView;
[UIView animateWithDuration:0.5
    delay:1.0
    options:UIViewAnimationCurveEaseOut
    animations:^{
        newView.frame = currentFrame;
    } 
    completion:^(BOOL finished){

    }];
于 2013-02-21T04:19:36.870 に答える
0

オーバーレイビューをaでラップし、プロパティをまたはUIWindowに設定します。windowLevelUIWindowLevelAlertUIWindowLevelStatusBar

于 2013-02-21T04:21:32.727 に答える