在navigationBar上查看部分(Feedly app like)

时间:2013-02-21 04:16:45

标签: ios xcode uiview uiviewcontroller modalviewcontroller

我有一个可以与过滤器一起订购的UITableView。 我没有使用模态视图,只想制作一个从屏幕左侧传来并部分覆盖我的tableView的视图动画。

以下是我想要“过滤视图”的示例:

没有过滤器:

Without the filter

使用过滤器:

With the filter

有什么可以做到的?

3 个答案:

答案 0 :(得分: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];

希望有所帮助!

答案 1 :(得分:1)

一种方法是,使用框架集添加此新视图,使视图位于当前视图之外,然后使用动画块将帧设置为当前位置的动画。您需要在self.navigationController.view上添加此新视图。

例如: -

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

    }];

答案 2 :(得分:0)

将覆盖的视图包裹在UIWindow中,并将windowLevel属性设置为UIWindowLevelAlertUIWindowLevelStatusBar