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

一种方法是,添加这个带有框架集的新视图,使视图位于当前视图之外,然后使用动画块将帧动画到当前位置。您需要在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并将windowLevel属性设置为UIWindowLevelAlertor UIWindowLevelStatusBar

于 2013-02-21T04:21:32.727 回答