2012-06-11 4 views
0

나는 게임 프로젝트에서 일하고 있습니다. 내가하고 싶은 것은 화면 상단에서 하단으로 레이블 그룹을 이동하고, 사용자가이 레이블을 읽고, 사라지도록합니다 어떤 방아쇠도없이 위쪽에서 아래쪽으로 미끄러지 듯 움직이는 라벨).목표 C 움직이는 레이블

루프의 타이머 변수를 사용하면 타이머 값에 따라 위치를 슬라이드하고 변경할 수 있다고 생각했습니다.

나는 약간의 연구를했지만, 나와 함께 기사를 공유하면, 내가 무엇을 찾아야하는지 알 수 있습니다.

감사합니다.

답변

2

@Chuck이 맞습니다. 정교하게 :

-(void)doTheLabelThing { 

    // assume all the labels are in a container view that is 320 wide and 100 tall 
    self.labelContainer.frame = CGRectMake(0, -100, 320, 100); 

    [UIView animateWithDuration:0.5 animations:^{ 
     // slide down 
     self.labelContainer.frame = CGRectMake(0, 360, 320, 100); 
    } completion:^(BOOL finished) { 
     // give user 3 seconds to read it 
     [UIView animateWithDuration:0.5 delay:3.0 options:0 animations:^{ 
      // fade out 
      self.labelContainer.alpha = 0.0; 
     } completion:^(BOOL finished) { 
      // restore everything to original state 
      self.labelContainer.alpha = 1.0; 
      self.labelContainer.frame = CGRectMake(0, -100, 320, 100); 
     }]; 
    }]; 
} 
+0

이것은 매우 도움이되며, 내가 논리를 실현하게 만들었습니다. 감사합니다. –

1

루프 또는 타이머를 사용하지 마십시오. Core Animation을 사용하십시오. animateWithDuration:animations: 또는 유사하게하고 원하는 위치로 새 위치를 설정하십시오.

+0

감사합니다. –