티스토리 뷰

//장면 전환 효과들 중에 옆으로 밀려서 나오고 스르륵 하고 그런효과들.. 책장 넘기는것 같은 효과 같은건 UIAnimationTransition
#import <QuartzCore/CoreAnimation.h>

        CATransition *transition;
        // First create a CATransition object to describe the transition
        transition = [CATransition animation];
        // Animate over 3/4 of a second
        transition.duration = 0.75;
        // using the ease in/out timing function
        transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
       
        // Now to set the type of transition. Since we need to choose at random, we'll setup a couple of arrays to help us.
        NSString *types[4] = {kCATransitionMoveIn, kCATransitionPush, kCATransitionReveal, kCATransitionFade};
        NSString *subtypes[4] = {kCATransitionFromLeft, kCATransitionFromRight, kCATransitionFromTop, kCATransitionFromBottom};
        int rnd = random() % 4;
        transition.type = types[rnd];
        if(rnd < 3) // if we didn't pick the fade transition, then we need to set a subtype too
        {
            transition.subtype = subtypes[random() % 4];
        }
       
        // Finally, to avoid overlapping transitions we assign ourselves as the delegate for the animation and wait for the
        // -animationDidStop:finished: message. When it comes in, we will flag that we are no longer transitioning.
        //transitioning = YES;
        transition.delegate = self;

//사용법
        [window.layer addAnimation:transition forKey:nil];
//혹은
            [self.loginView addAnimation:animation forKey:@"popup"];
            [self.loginView setFrame:CGRectMake(54, 20, 225, 155)];
            [self.view addSubview:loginView];



//그나마 팝업 비슷한 효과
    CAKeyframeAnimation *animation = [CAKeyframeAnimation
                                      animationWithKeyPath:@"transform"];
   
    CATransform3D scale1 = CATransform3DMakeScale(0.5, 0.5, 1);
    CATransform3D scale2 = CATransform3DMakeScale(1.2, 1.2, 1);
    CATransform3D scale3 = CATransform3DMakeScale(0.9, 0.9, 1);
    CATransform3D scale4 = CATransform3DMakeScale(1.0, 1.0, 1);
   
    NSArray *frameValues = [NSArray arrayWithObjects:
                            [NSValue valueWithCATransform3D:scale1],
                            [NSValue valueWithCATransform3D:scale2],
                            [NSValue valueWithCATransform3D:scale3],
                            [NSValue valueWithCATransform3D:scale4],
                            nil];
    [animation setValues:frameValues];
   
    NSArray *frameTimes = [NSArray arrayWithObjects:
                           [NSNumber numberWithFloat:0.0],
                           [NSNumber numberWithFloat:0.5],
                           [NSNumber numberWithFloat:0.9],
                           [NSNumber numberWithFloat:1.0],
                           nil];   
    [animation setKeyTimes:frameTimes];
   
    animation.fillMode = kCAFillModeForwards;
    animation.removedOnCompletion = NO;
    animation.duration = .2;
   
    [targetViewController.view.layer addAnimation:animation forKey:@"popup"];

'나름 프로그래밍? > Objective-C' 카테고리의 다른 글

respondsToSelector  (0) 2010.04.26
현재 시각 가져오기  (0) 2010.04.22
UIImageView  (0) 2010.04.21
UIWebView  (0) 2010.04.21
Objective-C 에서의 Singleton  (2) 2010.04.17
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/12   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
글 보관함