닥치고 기억을 만들면서 버튼을 터치 하면 뒤집게 하는 효과 작성에
이용된 코드이다.
이용된 코드이다.
- (void) toFrontBtnImage: (UIButton *)btn
{
UIImage * img;
NSString * fileName;
fileName = (NSString *)[mCountryNameArray objectAtIndex:flagsArray[btn.tag]];
img = [UIImage imageNamed:fileName];
flagSide[btn.tag] = FRONT;
CGPoint startpoint = CGPointMake(0, 0);
[img drawAtPoint:startpoint];
[UIView beginAnimations:@"toFrontBtnImage" context:nil];
[UIView setAnimationDuration:ANIMATION_DURATION];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:btn cache:YES];
[btn setImage:img forState:UIControlStateNormal];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
[UIView commitAnimations];
btn.enabled = YES;
}
- (void) toBackBtnImage: (UIButton *)btn
{
UIImage * img;
img = [UIImage imageNamed:@"back.png"];
flagSide[btn.tag] = BACK;
CGPoint startpoint = CGPointMake(0, 0);
[img drawAtPoint:startpoint];
[UIView beginAnimations:@"toBackBtnImage" context:nil];
[UIView setAnimationDuration:ANIMATION_DURATION];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut]; // 빠져나갈때 가속
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:btn cache:YES];
[btn setImage:img forState:UIControlStateNormal];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
[UIView commitAnimations];
btn.enabled = YES;
}
위 함수는 하나는 국기 모양으로 뒤집고
하나는 백 배경으로 뒤집는다.
animationDidStop 함수를 만들어서
에니메이션이 종료하면 처리 할수 있도록 처리 한다.
- (void) animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context
{
if ([animationID isEqualToString:@"toFrontBtnImage"]){
//처리 하고 싶은 일...
}
댓글 없음:
댓글 쓰기