UITextfield的contentoffset上的UIView.animateWithDuration:剪切文本(Swift) [英] UIView.animateWithDuration on UITextfield's contentoffset: It clips the text (Swift)

查看:122
本文介绍了UITextfield的contentoffset上的UIView.animateWithDuration:剪切文本(Swift)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码:

    UIView.animateWithDuration(30, delay: 0, options: UIViewAnimationOptions.CurveLinear, animations: {
        self.textView.contentOffset = CGPointMake(0, 700)
        }, completion: nil)

如果contentOffset最多约为100,则动画可以正常工作,并且所有文本都是可见的。高于此值的所有操作都会导致在动画过程中textlabel开头的文本消失。 contentOffset越高,动画过程中消失的文本越多。所以我看到了一段时间,然后剩下的文本变成了动画。另外:动画制作完成后,当我向上滚动时,所有文本都将再次可见。

If the contentOffset is up to about 100, the animation works correctly and all text is visible. Everything higher than that leads to the disappearance of text at the beginning of the textlabel during the animation. The higher the contentOffset, the more text disappears during the animation. So I see white space for a while and then the remaining text comes into animation. Also: Once the animation is done, all text is visible again when I scroll up.

我已经尝试了各种超级视图中的多个UITextviews。一般的想法是一种类似于动画的点数,其中所有文本缓慢向上移动约30秒。

I have tried multiple UITextviews in various superviews. The general idea is a kind of Credits like animation where all text moves slowly upwards for about 30 seconds.

推荐答案

您可以尝试循环小型动画,如下所示。

You can try looping small animations together like the following.

func animate(count:Int)
{
    if (count > 100)
    {
        return
    }
    UIView.animateWithDuration(1, delay: 0, options: UIViewAnimationOptions.CurveLinear, animations: {

        self.textView.contentOffset = CGPointMake(0, self.textView.contentOffset.y + 10)
        }, completion: { finished in
            dispatch_async(dispatch_get_main_queue(),{
                self.animate(count+1)
        })
    })

}

这篇关于UITextfield的contentoffset上的UIView.animateWithDuration:剪切文本(Swift)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆