업데이트 됨
실행중인 텍스트 줄을 만들고 싶습니다.독립적 인 스레드에서 독립적으로 실행중인 텍스트 줄
-(void)viewDidLoad
{
CGSize mySize = CGSizeZero;
mySize = [kGrindFMRunningText sizeWithFont:[UIFont fontWithName:@"Verdana" size:16] constrainedToSize:CGSizeMake(4000, 30) lineBreakMode:UILineBreakModeWordWrap];
runningText = [[UIScrollView alloc] initWithFrame:CGRectMake(60, -5, 260, 50)];
grind_fm_text = [[UILabel alloc] initWithFrame:CGRectMake(0, 15, mySize.width, 30)];
[grind_fm_text setUserInteractionEnabled:NO];
[grind_fm_text setBackgroundColor:[UIColor clearColor]];
[grind_fm_text setTextColor:[UIColor whiteColor]];
[grind_fm_text setFont:[UIFont fontWithName:@"Verdana" size:16]];
[grind_fm_text setText:kGrindFMRunningText];
[runningText addSubview:grind_fm_text];
[grind_fm_text release];
[self animate];
}
- (void)animate
{
[UIView animateWithDuration:10.0 delay:0. options:UIViewAnimationOptionCurveLinear|UIViewAnimationOptionBeginFromCurrentState animations:^{
grind_fm_text.frame = CGRectMake(-grind_fm_text.frame.size.width, 15, grind_fm_text.frame.size.width, grind_fm_text.frame.size.height);
// Do your animation in one direction until text is gone
} completion:^(BOOL finished){
grind_fm_text.frame = CGRectMake(260, 15, grind_fm_text.frame.size.width, grind_fm_text.frame.size.height);
// Move scroll position back to original position
[self animate]; // Then call animate again to repeat
}];
}
-(void)songChange
{
CGSize mySize = CGSizeZero;
mySize = [result sizeWithFont:[UIFont fontWithName:@"Verdana" size:16] constrainedToSize:CGSizeMake(4000, 30) lineBreakMode:UILineBreakModeWordWrap];
grind_fm_text.frame = CGRectMake(grind_fm_text.frame.origin.x, 15, mySize.width, 30);
grind_fm_text.text = result;;
[self animate];
}
- (void)startStopStream {
[streamer stop];
//[bufferIndicator stopAnimating];
[CATransaction begin];
[self.view.layer removeAllAnimations];
[CATransaction commit];
grind_fm_text.text = kGrindFMRunningText;
CGSize mySize = CGSizeZero;
mySize = [kGrindFMRunningText sizeWithFont:[UIFont fontWithName:@"Verdana" size:16] constrainedToSize:CGSizeMake(4000, 30) lineBreakMode:UILineBreakModeWordWrap];
grind_fm_text.frame = CGRectMake(grind_fm_text.frame.origin.x, 15, mySize.width, 30);
[self animate];
}
[CATransaction begin]; [myView.layer removeAllAnimations]; [CATransaction commit];
은 저에게 적합하지 않습니다. UIViewAnimationOptionCurveLinear|UIViewAnimationOptionBeginFromCurrentState
은 이상하게 작동합니다. 먼저 보았 듯이 완료 블록을 수행하지 않거나 그렇지는 않지만 애니메이션이 다시 시작되지 않습니다. 그리고 버튼을 클릭해도 아무 일도 일어나지 않지만 두 번 클릭하면 애니메이션이 다른 방향에서 시작되고 멈출 때까지 느려집니다.
고맙습니다. 그것은 나를 위해 작동하지만, 10 초와 함께 사용할 때. 애니메이션은 처음에는 정상 속도 (첫 번째 문자가 표시 될 때) 인 것처럼 보였지만 속도가 빨라졌으며 마지막 두 글자가 표시되면 정상 속도로 다시 나타납니다. 10 초 동안 두 번째 코드 샘플을 사용하십시오. 내 질문을 업데이 트하겠습니다 – Aft3rmath
그 주소를 내 대답을 업데이 트 –
당신은 위대한 분입니다! 그리고 한 가지 더 질문합니다. 버튼을 클릭하면 애니메이션이 시작될 때부터 시작해야합니다. 현재 애니메이션을 중단하고 [self animation]을 다시 호출하려면 어떻게해야합니까? 현재 애니메이션을 중지하지 않으면 [자동 애니메이션]이 작동하지 않습니다. – Aft3rmath