我确信有一种简单的方法可以做到这一点,但我被困住了.假设我有一个点列表:
Point[] list = {pointA, pointB, pointC, ...}
Run Code Online (Sandbox Code Playgroud)
我想通过每个点动画一个ImageView所以我尝试了这个:
id = 0;
AnimatorListenerAdapter animEnd = new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
id++;
if(id != list.length) {
iv.animate()
.translationX(list[id].getX())
.translationY(list[id].getY())
.setDuration(200)
.setListener(this);
}
}
};
iv.animate()
.translationX(list[id].getX()).translationY(list[id].getY())
.setDuration(200).setListener(animEnd);
Run Code Online (Sandbox Code Playgroud)
它有效,但每个动画之间有一点延迟.
任何的想法?谢谢 !
我知道已经有一些问题,但我找不到解决方案.有一个非常简单的代码可以在我的一个项目上正常工作,但不能在另一个项目上工作:
这是UIView的子类的代码.
import UIKit
class test : UIView {
init(frame: CGRect, color: UIColor) {
super.init(frame: frame)
self.backgroundColor = color
self.userInteractionEnabled = true
}
required init(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
super.touchesBegan(touches, withEvent: event)
var alert = UIAlertView()
alert.title = "lol"
alert.message = "lol"
alert.addButtonWithTitle("Ok")
alert.show()
}
}
Run Code Online (Sandbox Code Playgroud)
我确信解决方案很简单,但我找不到它.