连续动画 - Watchkit

时间:2015-03-22 22:20:54

标签: ios swift watchkit

我希望为Apple Watch应用程序提供各种动画。我使用了一系列图像,动画方法是startAnimatingWithImagesInRange()。每当我有连续的动画指令时,只执行代码中的最后一个。代码如下:

myImage.setImageNamed("testImage")

myImage.startAnimatingWithImagesInRange(NSRange(location: 0, length: 90), duration: 3, repeatCount: 1)

myImage.startAnimatingWithImagesInRange(NSRange(location: 90, length: 180), duration: 3, repeatCount: 1)

在上面的代码中,只会播放第二个动画。我甚至尝试将它们放在单独的函数中,所以我会单独调用每个函数,但它仍然只会在我的代码中播放最后一个动画。我对此非常陌生,因此我确信有更好的方法,但经过数小时和数小时的研究后,我无法找到解决方案或在网上找到解决方案。

2 个答案:

答案 0 :(得分:1)

这很简单,因为1 + 1:)

这是你想要的:

public void YUVImage(View view) {
    Bitmap bitmap = ((BitmapDrawable)OrignalImg.getDrawable()).getBitmap();//reading image from imageView

    int bwidth = bitmap.getWidth();
    int bheight = bitmap.getHeight();
    Bitmap mutableBitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true);
    Canvas c = new Canvas(mutableBitmap);

    Toast.makeText(this, "Done 1 ok ",
            Toast.LENGTH_LONG).show();  

    Paint paint = new Paint();
    paint.setAntiAlias(true);
    paint.setFilterBitmap(true);

    Toast.makeText(this, "Done 2 ok ",
          Toast.LENGTH_LONG).show();    

    ColorMatrix yuvMatrix = new ColorMatrix();
    yuvMatrix.setRGB2YUV();

    Toast.makeText(this, "Now Yuv ok ",
          Toast.LENGTH_LONG).show();

    ColorFilter filter = new ColorMatrixColorFilter(yuvMatrix);
    paint.setColorFilter(filter);
    Matrix matrix = new Matrix();
    matrix.setTranslate(2*bwidth, 2*bheight); 
    c.drawBitmap(mutableBitmap, 0, 0, paint);

    Toast.makeText(this, "Canvas ok ",
          Toast.LENGTH_LONG).show();    

    ImageView mImg=null;
    mImg = (ImageView) findViewById(R.id.imageView1);
    mImg.setImageDrawable(new BitmapDrawable(getResources(), mutableBitmap));
    //mImg.setImageBitmap(newBitmap);

     Toast.makeText(this, "YUV Image converted",
             Toast.LENGTH_LONG).show(); 

  }

TimelineKit - 随时给我一些关于我的小框架的反馈。 :)

答案 1 :(得分:0)

手表不会为您排队动画,因此请使用NSTimer,其延迟时间等于第一个动画的持续时间,并在计时器触发后开始第二个动画。