【发布时间】:2011-03-22 13:46:50
【问题描述】:
如何在 iPhone 中从左向右滑动文本?
【问题讨论】:
标签: iphone objective-c cocoa-touch animation
如何在 iPhone 中从左向右滑动文本?
【问题讨论】:
标签: iphone objective-c cocoa-touch animation
[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];
【讨论】:
你可以在 Label 的位置使用 UIView 动画:
[UIView beginAnimations];
CGRect fr = label.frame;
fr.origin.x = target_x_position;
label.frame = fr;
[UIView commitAnimation];
【讨论】:
为此,您需要在滚动视图中使用 UILabel 或 UITextView。 生成具有必要宽度的滚动视图并将 UITextView 作为 addSubView 添加到此滚动视图。
<UIScrollViewDelegate> //set the delegate of ScrollView to call it's delegate methods and allow paging to be done in ScrollView.
-(void)ScrollViewdidScroll:(UIScrollView *)UIScrollV
{
}
【讨论】: