Resizable UILabel which scrolls across the screen

前端 未结 2 473
野的像风
野的像风 2020-12-08 06:12

Right, I\'m trying to get a label with text in it (done already obviously), which scrolls across the screen.

The text that is input into the label is done by a UITex

相关标签:
2条回答
  • 2020-12-08 06:32

    The label resize worked great thanks!

    Now, i've put the label into the scrollview and i've got that showing up.. but I'm now not sure of the exact animations to add to that. I tried some of the ones on the link you gave me, but they're not working.

    EDIT: Nevermind, I've got it all working now.

    CGPointMake(x, x) is what i needed for the contentOffset.

    0 讨论(0)
  • 2020-12-08 06:35

    I believe something similar to the solution for this question would work for this case.

    You could embed the UILabel in a UIScrollView, with the UIScrollView set to the max size of the label that you want to display on the screen at one time. The UIScrollView would need to have its scroll indicators turned off using its showsHorizontalScrollIndicator and showsVerticalScrollIndicator properties. On a change of text, you could do the following:

    [lblMessage setText: txtEnter.text];
    [lblMessage sizeToFit];
    scrollView.contentSize = lblMessage.frame.size;
    

    followed by the panning animation code as described in the above-linked question, with the frame to be panned to being the far right of the UILabel. This would cause the text to scroll at a constant rate across the label. If you want the label to scroll back to the beginning, you could use the UIView setAnimationRepeatAutoreverses: and setAnimationRepeatCount: methods in the beginning of your animation block.

    0 讨论(0)
提交回复
热议问题