UIView的动画列表,可以使用swift依次为UIButton或UIImageView

时间:2015-03-02 16:14:32

标签: ios swift uiview uiimageview

我正在尝试创建一个我已经为android做过的功能。 该函数能够获取视图列表,并将按顺序显示它们。 它是这样的:

void displayViews(List<View> listOfViews, int delayTime, CompletionListener listner{
    // code of applying animation on the views here
    int startDelay = mDelay; // milliseconds
        int numberOfViews = listOfViews.size();

        for (int i = 0; i < numberOfViews; i++) {
            final Animation animator = AnimationUtils.loadAnimation(mContext, R.anim.FadeIn);
            animator.setStartOffset(startDelay);
            startDelay += mOffSet; // every view will start after 100 milliseconds from the other
            final View currentView = listOfViews.get(i);
            final int indexOfCurrentCheckedItem = i;

            animator.setAnimationListener(new Animation.AnimationListener() {
                @Override
                public void onAnimationStart(Animation animation) {}
                @Override
                public void onAnimationEnd(Animation animation) {
                    // if index of current item == number of views, SO this is the last view
                    //      in the list, which means the animation is finished, lets do what
                    //         we wanna after the animation finishes
                    if (listener != null) {
                        if (indexOfCurrentCheckedItem == mNumOfViews - 1)
                            listner.doIt();
                    } 
                    // after animation finishes
                }
                @Override
                public void onAnimationRepeat(Animation animation) {}
            });

            mMainUIThreadHandler.post(new Runnable() {
                @Override
                public void run() {
                    currentView.startAnimation(animator);
                }
            });
        }
}

这样使用此功能我将为每个视图启动动画延迟,当最后一个动画完成后,将触发完成侦听器。

我检查了可能帮助我找不到的UIView函数的函数。我需要像view.setAnimationWithDelay

这样的东西

问题1 我可以通过引用来为swift中的UIView添加动画吗?

问题2 是否可以使用?

传递我想要在listOfViews上应用的动画

0 个答案:

没有答案