如何在iPhone中从左向右滑动文本?

时间:2011-03-22 13:46:51

标签: iphone objective-c cocoa-touch animation

如何在iPhone中从左向右滑动文字?

3 个答案:

答案 0 :(得分:5)

[label setFrame:CGRectMake(278, 32, 42, 29)];    // Right most position  
[UIView beginAnimations:nil context:nil]; 

[UIView setAnimationDuration:0.5]; 
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[label setFrame:CGRectMake(0, 20, 42, 29)];  //left most position
[UIView commitAnimations];

答案 1 :(得分:4)

你可以在Label的位置使用UIView动画:

[UIView beginAnimations];
CGRect fr = label.frame;
fr.origin.x = target_x_position;
label.frame = fr;
[UIView commitAnimation];

答案 2 :(得分:0)

为此,您需要在滚动视图中使用UILabel或UITextView。 生成具有所需宽度的Scroll视图,并将UITextView作为addSubView添加到此Scroll视图。

<UIScrollViewDelegate> //set the delegate of ScrollView to call it's delegate methods and allow paging to be done in ScrollView.

-(void)ScrollViewdidScroll:(UIScrollView *)UIScrollV
{

}