有一个 UIImageView ,我想在其中加两个动画,同时运行。第一个动画设置透明度从1到10。第二个动画移动 UIView 。当 UIView 加载完成后,两个动画同时开始。
可能实现么?请高手帮忙,谢谢。
CGPoint movePoint = Your end animation point;
yourView.opaque = 0.0f;
[UIView animateWithDuration:2.0
animations:^{
yourView.center = movePoint;
yourview.opaque = 1.0
}
completion:^(BOOL finished){
//Animation completed
}];
可以用补间动画完成,
1:工程中,建立/res/anim/animation.xml,内容如下:
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/cycle_interpolator"> <!--插针频率-->
<!--下面这两个属性值自己填写-->
<alpha></alpha> <!--透明度-->
<translate></translate><!--移动-->
</set>
2:在java代码中用Animation anim = AnimationUtils.loadAnimation(getContext(), R.anim.animation);
方法得到。
3:如果要在显示UIView 的时候就启动动画,可以在当前Activity的
public void onWindowFocusChanged(boolean hasWindowFocus) {
// TODO Auto-generated method stub
super.onWindowFocusChanged(hasWindowFocus);
}
方法中开启动画:UIView .startAnimation();