2014-05-01 2 views
1

내 앱에 Navigation Bar이 있습니다. 내가보기에 원하는애니메이션을 사용하여 UINavigationBar에서보기를 전환하는 방법은 무엇입니까?

enter image description here

아래 그림과 같이

거꾸로에서오고 전체 UINavigationBar을 포함, 그것은 UIView 수 있습니다. 그런 다음 다시 애니메이션으로 넘어갑니다.

+0

를 호출? – amar

+0

그냥보기 (UIIMage 또는 다른 uiview) 위에서 와서 전체 탐색을 커버하고 그것이 왔던 곳에서 위로 거꾸로 가야합니다. –

+0

프레임을 (0, -480,320,480)으로 설정하고 내비게이션 컨트롤러 위에 프레임을 추가하고 애니메이션 블록에서 프레임을 (0,0,320,480)으로 변경하십시오. – amar

답변

4

UIAlertView를 상속 받아 기본보기에 표시해야합니까?

#import <Foundation/Foundation.h> 

@interface MyAlertView : NSObject 
@property (nonatomic,retain) UIButton *alertBtn; 
@property (nonatomic,retain) UIButton *closeBtn; 
@property (nonatomic,retain) NSTimer *timer; 
@property(nonatomic) int loadTime; 

-(void) setAlert :(UIWindow *)currentWindow; 
-(void) showAlert :(NSString *)alertText; 
-(void)closeAlert; 
@end 



#import "MyAlertView.h" 

@implementation MyAlertView 
@synthesize loadTime; 
@synthesize closeBtn,alertBtn,timer; 
BOOL timessss=FALSE; 
-(void) setAlert :(UIWindow *)currentWindow{ 
    loadTime=3; 

    self.alertBtn=[[UIButton alloc] init]; 
    self.alertBtn.titleLabel.numberOfLines=2; 
    self.closeBtn=[[UIButton alloc] init]; 
    self.closeBtn.hidden=YES; 
    self.alertBtn.titleLabel.adjustsFontSizeToFitWidth=YES; 
    [[self alertBtn] setBackgroundImage:[UIImage imageNamed:@"orangeBar"] forState:UIControlStateNormal]; 
    [[self closeBtn] setBackgroundImage:[UIImage imageNamed:@"cross-1"] forState:UIControlStateNormal]; 
    [[self closeBtn] addTarget:self action:@selector(cancelAlert) forControlEvents:UIControlEventTouchUpInside]; 
    [[self alertBtn] addTarget:self action:@selector(cancelAlert) forControlEvents:UIControlEventTouchUpInside]; 
    [self.alertBtn setFrame:CGRectMake(0, 20.0f, 320.0f, 50.0f)]; 
    [self.closeBtn setFrame:CGRectMake(294, 17.0f, 15.0f, 15.0)]; 
    [self.closeBtn setHidden:YES]; 
    [self.alertBtn setHidden:YES]; 

    [currentWindow addSubview:self.alertBtn]; 
    //[self.alertBtn addSubview:self.closeBtn]; 

    //[currentWindow addSubview:self.closeBtn]; 

} 
-(void) cancelAlert{ 
    [UIView transitionWithView:self.alertBtn 
         duration:0.7 
         options:UIViewAnimationOptionTransitionFlipFromBottom 
        animations:NULL 
        completion:NULL]; 

    [self.alertBtn setHidden:YES]; 
    [self.closeBtn setHidden:YES]; 
    [timer invalidate]; 
    timessss=FALSE; 

} 
-(void) showAlert :(NSString *)alertText{ 
    if(alertBtn.isHidden); 
    else return; 

    [self.alertBtn setTitle:alertText forState:UIControlStateNormal]; 
    [UIView transitionWithView:self.alertBtn 
         duration:0.7 
         options:UIViewAnimationOptionTransitionFlipFromTop 
        animations:NULL 
        completion:NULL]; 
    [UIView transitionWithView:self.closeBtn 
         duration:0.7 
         options:UIViewAnimationOptionTransitionFlipFromTop 
        animations:NULL 
        completion:NULL]; 

    [self.alertBtn setHidden:NO]; 

    timer = [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(closeAlert) userInfo:nil repeats:YES]; 
    [timer fire]; 

} 
-(void)closeAlert{ 
    if (timessss) { 
     [UIView transitionWithView:self.alertBtn 
          duration:0.7 
          options:UIViewAnimationOptionTransitionFlipFromBottom 
         animations:NULL 
         completion:NULL]; 

     [self.alertBtn setHidden:YES]; 
     [self.closeBtn setHidden:YES]; 
     [timer invalidate]; 
     timessss=FALSE; 

    } 
    else{ 
     timessss=TRUE; 
     [self.closeBtn setHidden:NO]; 

    } 

} 
@end 

아래

참조 코드는 현재의 역 할 ,,,, 세계적으로 속성을 정의하는 동안 같은

//In View DidLoad 
UIWindow* currentWindow = [UIApplication sharedApplication].keyWindow; 
alert=[[MyAlertView alloc] init]; 
[alert setAlert:currentWindow]; 

//Wherever you want to show Alert on your navigation bar. 
[alert showAlert:@"Your Message"]; 
+1

+1에 대한 자세한 아직 간단한 대답을 위해 – iBug

관련 문제