문제

화면 중간에 눌렀을 때 짧은 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];

다른 팁

예. uiimageview에 iboutlet을 만들면 코드에서 업데이트 할 수 있습니다. 예를 들어, 그것의 사용 영상 표시해야 할 UIIMAGE를 설정하는 속성. 또는 앱의 리소스에 이미지를 추가하고 인터페이스 빌더의 UIIMAGEVIEW와 연결할 수 있습니다. iPhone이 최적화되었으므로 .png 파일을 사용하십시오.
uiimageview는 uiview이므로 모든 일반적인 핵심 애니메이션 행동 양식 사용할 수 있습니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top