1
내 앱에 Navigation Bar
이 있습니다. 내가보기에 원하는애니메이션을 사용하여 UINavigationBar에서보기를 전환하는 방법은 무엇입니까?
아래 그림과 같이
거꾸로에서오고 전체 UINavigationBar
을 포함, 그것은 UIView
수 있습니다. 그런 다음 다시 애니메이션으로 넘어갑니다.
내 앱에 Navigation Bar
이 있습니다. 내가보기에 원하는애니메이션을 사용하여 UINavigationBar에서보기를 전환하는 방법은 무엇입니까?
아래 그림과 같이
거꾸로에서오고 전체 UINavigationBar
을 포함, 그것은 UIView
수 있습니다. 그런 다음 다시 애니메이션으로 넘어갑니다.
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에 대한 자세한 아직 간단한 대답을 위해 – iBug
를 호출? – amar
그냥보기 (UIIMage 또는 다른 uiview) 위에서 와서 전체 탐색을 커버하고 그것이 왔던 곳에서 위로 거꾸로 가야합니다. –
프레임을 (0, -480,320,480)으로 설정하고 내비게이션 컨트롤러 위에 프레임을 추가하고 애니메이션 블록에서 프레임을 (0,0,320,480)으로 변경하십시오. – amar