How do I create an animated credits page?

I have a UITextView that has a lot of content (like a credit view) and I want to create an auto scroll view for it (something like the credits page for Firefox) where it automatically scrolls the names

I tried the following but it is not smooth and I also require it to happen automatically when the user navigates to this view

CGPoint scrollPoint = textView.contentOffset;

scrollPoint.y= scrollPoint.y+10;

[textView setContentOffset:scrollPoint animated:YES];

      

Any directions?

+2


source to share


3 answers


Since it UITextView

is a subclass UIScrollView

, you can use it scrollRectToVisible:animated:

to scroll with animation to any point you want.



The PageControl example demonstrates its use (although it scrolls horizontally).

+1


source


So far I've done it, but still it's behind the scenes ...

Any suggestions?



- (void)viewDidLoad {

    [super viewDidLoad];

[self run];

}

-(void)run{

    CGRect Frame1 = CGRectMake(5.0,5.0, 100.0,400.0);
    CGPoint scrollPoint = textView.contentOffset;

    scrollPoint.y= scrollPoint.y+100;

    [textView setContentOffset:scrollPoint animated:YES];

    [textView scrollRectToVisible:Frame1 animated:YES];
    NSTimer *time;
    time=[NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(run) userInfo:nil repeats:YES]; 

}

      

0


source


Neither scrollRectToVisible: animated:

, nor setContentOffset: animated:

have properties to control the speed or duration, in which the animation, so they will quickly scroll to the destination. They are not good solutions for something like loans that need to roll slowly.

Using UIView animateWithDuration:

and then passing contentOffset

in an animation block is probably the best way to do this. However, there is a bug that clamps the text at the top if the text length is too long (even in the IOS 10.0 SDK). There are two viable issues discussed for this error:

UIView.animateWithDuration on contentoffset UITextfield: it will copy text (Swift)

0


source







All Articles