代码之家  ›  专栏  ›  技术社区  ›  raaz

如何创建动画信用页?

  •  2
  • raaz  · 技术社区  · 16 年前

    我有一个有很多内容的uitextview(比如credit视图),我想为它创建一个自动滚动视图(比如firefox的credits页面) 自动滚动名字

    我已经尝试了以下操作,但它并不平滑,我还要求当用户转到该视图时自动执行此操作

    CGPoint scrollPoint = textView.contentOffset;
    
    scrollPoint.y= scrollPoint.y+10;
    
    [textView setContentOffset:scrollPoint animated:YES];
    

    有什么指导吗?

    3 回复  |  直到 16 年前
        1
  •  1
  •   Shaggy Frog    16 年前

    自从 UITextView UIScrollView ,您可以使用 scrollRectToVisible:animated: 方法将动画滚动到所需的任意点。

    这个 PageControl 示例代码演示了它的用途(尽管它是水平滚动的)。

        2
  •  0
  •   John Hascall    10 年前

    到目前为止我已经做到了,但仍然不顺利…

    有什么建议吗?

    - (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]; 
    
    }
    
        3
  •  0
  •   Community Mohan Dere    9 年前

    既不 scrollRectToVisible: animated: 也不 setContentOffset: animated: 有一个属性来控制 速度 期间 在其中发生动画,因此两者都将相当快地滚动到目标点。对于像credits这样的东西,它们不是很好的解决方案,credits应该滚动得很慢。

    使用 UIView animateWithDuration: 然后经过一个 contentOffset 在动画块中可能是最好的方法。但是,如果文本的长度太长(即使在ios 10.0sdk中),则会在顶部剪辑文本。这里讨论的这个bug有两个可行的解决方案:

    UIView.animateWithDuration on UITextfield's contentoffset: It clips the text (Swift)