How to move text from right to left in iOS programmatically

后端 未结 9 1744
野趣味
野趣味 2020-12-28 11:33

I want to show some text in my app like moving text (Scrolling with animation from right to left). How to do this programmatically?

I took UIViewcontroller

9条回答
  •  醉梦人生
    2020-12-28 11:50

    Yo can use UIView Animation Blocks for that

     [UIView animateWithDuration:5.0f delay:0.0f options:UIViewAnimationOptionTransitionNone animations:^{
                yourLabel.center = CGPointMake(0, yourLabel.center.y);
            } completion:NULL ];
    

    And if you want something like autoreverses

    [UIView animateWithDuration:5.0f delay:0.0f options:UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse | UIViewAnimationOptionBeginFromCurrentState animations:^{
                yourLabel.center = CGPointMake(0, yourLabel.center.y);
            } completion:NULL ];
    

提交回复
热议问题