우리은행 아이폰 앱을 사용하면은 아래 탭바가 애니메이션 처리되는 것을 알 수 있다.

 

이걸 보고 나도 궁금해서 찾아보았다.

 기능 똑 같이 구현했는데 아무리 아이폰이라도 결국 이쁜 이미지가 없으면 말짱 꽝이라는걸 느꼈다.


우선 인터페이스 빌더에서 아래 UIView 오브젝트를 넣어준다.
'올리기', '내리기' 버튼은 당연 IBAction 잡아준다.

#import <UIKit.h>


@interface AnimationTestAppDelegate : NSObject<UIApplicationDelegate>

@property (nonatomic, retain) IBOutlet UIWindow *window;

@property (nonatomic, retain) IBOutlet UIView *viewTabbar;

@property (nonatomic, assign) CGRect viewFrame;

 

-(IBAction)clickedUp:(id)sender;

-(IBAction)clickedDown:(id)sender;

 

@end

//AnimationTestAppDelegate.m 

#import "AnimationTestAppDelegate.h"

@implementation AnimationTestAppDelegate

@synthesize window = _window;
@synthesize viewTabbar;
@synthesize viewFrame;

#pragma mark-
#pragma mark button events
-(IBAction)clickedUp:(id)sender
{
    // 애니메이션을 보여준다.
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.3];
    
    self.viewTabbar.frame = viewFrame;
    
    
    [UIView commitAnimations];    
}

-(IBAction)clickedDown:(id)sender
{
    // 애니메이션을 보여준다.
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.3];
    
    CGRect screen = [[UIScreen mainScreen] bounds];
    CGRect rect = self.viewTabbar.frame;
    rect.origin.y = screen.size.height;
    self.viewTabbar.frame = rect;
    
    
    [UIView commitAnimations];
}
#pragma mark-


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    self.viewFrame = viewTabbar.frame;
    
    [self.window makeKeyAndVisible];
    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application
{
    /*
     Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
     Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
     */
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    /*
     Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
     If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
     */
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
    /*
     Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
     */
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    /*
     Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
     */
}

- (void)applicationWillTerminate:(UIApplication *)application
{
    /*
     Called when the application is about to terminate.
     Save data if appropriate.
     See also applicationDidEnterBackground:.
     */
}

- (void)dealloc
{
    [viewTabbar release];
    
    [_window release];
    [super dealloc];
}

@end

이벤트 부분과 앱 처음 구동될때 인터페이스빌더에서 잡아주었던 위치 저장 부분 'viewFrame'만 확인하면 된다.
이제 UIView로 구현된 부분에 다른 컨트롤들을 올리면 탭바 비스무리 하게 사용할 수 있다.



저작자 표시
신고
posted by 뚱2