2013-02-21 46 views
0

我有一個UITableView可以與過濾器一起訂購。 而不是使用模態視圖,我想只是從屏幕左側進行視圖動畫,並部分覆蓋我的tableView。查看partialBar上的導航欄(Feedly應用程序)

這裏是什麼,我想我的 「過濾器視圖」 看起來像一個爲例:

沒有過濾器:

Without the filter

與過濾器:

With the filter

有什麼可以做的伎倆?

回答

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

一種方法是,添加具有框架設置的新視圖,使視圖位於當前視圖之外,然後使用動畫塊將框架設置爲當前位置的動畫。您需要在self.navigationController.view上添加此新視圖。

對於例如: -

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

    }]; 
+0

對您有幫助嗎?對此有何更新? – iDev 2013-03-07 20:02:30

0

裹在一個UIWindow的疊加視圖和windowLevel屬性設置爲UIWindowLevelAlertUIWindowLevelStatusBar