간단한 애니메이션 [iPhone
-
06-07-2019 - |
문제
화면 중간에 눌렀을 때 짧은 5-10 프레임 애니메이션을 트리거하고 싶은 몇 가지 Uibutton이 있습니다. IB에 uiimageview를 삭제하고 프로그래밍 방식으로 업데이트 할 수 있습니까? 지나치게 복잡 할 필요는 없으며, 작은 프로젝트이기 때문에 지금은 하드 코딩 된 경우도 신경 쓰지 않습니다.
감사.
해결책
다음은 몇 프레임만으로 애니메이션을하는 가장 쉬운 방법의 예입니다.
선언 IBOutlet UIImageView *timerAnimation
IB의 uiimageview에 연결하십시오. 아래에 필요한 것과 같이 리소스에 몇 가지 이미지를 추가하십시오. 그런 다음 이미지를 배열에로드 - 코드를 참조하십시오.
timerAnimation.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"timer00.png"],
[UIImage imageNamed:@"timer01.png"],
[UIImage imageNamed:@"timer02.png"],
[UIImage imageNamed:@"timer03.png"],
[UIImage imageNamed:@"timer04.png"],
[UIImage imageNamed:@"timer05.png"],
[UIImage imageNamed:@"timer06.png"],
[UIImage imageNamed:@"timer07.png"],
[UIImage imageNamed:@"timer08.png"],
[UIImage imageNamed:@"timer09.png"],
[UIImage imageNamed:@"timer10.png"],
[UIImage imageNamed:@"timer11.png"],
[UIImage imageNamed:@"timer12.png"],
[UIImage imageNamed:@"timer13.png"],
[UIImage imageNamed:@"timer14.png"],
[UIImage imageNamed:@"timer15.png"],
[UIImage imageNamed:@"timer16.png"],
[UIImage imageNamed:@"timer17.png"],
[UIImage imageNamed:@"timer18.png"],
[UIImage imageNamed:@"timer19.png"],
[UIImage imageNamed:@"timer20.png"],
[UIImage imageNamed:@"timer21.png"],
[UIImage imageNamed:@"timer22.png"],
[UIImage imageNamed:@"timer23.png"],
[UIImage imageNamed:@"timer24.png"],
[UIImage imageNamed:@"timer25.png"],
[UIImage imageNamed:@"timer26.png"],
[UIImage imageNamed:@"timer27.png"],
[UIImage imageNamed:@"timer28.png"],
[UIImage imageNamed:@"timer29.png"],
[UIImage imageNamed:@"timer30.png"],
[UIImage imageNamed:@"timer31.png"],
[UIImage imageNamed:@"timer32.png"],
[UIImage imageNamed:@"timer33.png"],
[UIImage imageNamed:@"timer34.png"],
[UIImage imageNamed:@"timer35.png"],
// [UIImage imageNamed:@"timer36.png"], save last picture for "times up"
nil];
timerAnimation.animationDuration = 5.0;
timerAnimation.animationRepeatCount = 1;
[timerAnimation startAnimating];
전화 할 때까지 애니메이션이 실행됩니다 [timerAnimation stopAnimating];
제휴하지 않습니다 StackOverflow