public override void ViewDidLoad ()
{
base.ViewDidLoad ();
// Perform any additional setup after loading the view, typically from a nib.
List<UIImage> myImages = new List<UIImage>();
myImages.Add(UIImage.FromFile(@"image/1.jpeg"));
myImages.Add(UIImage.FromFile(@"image/2.jpeg"));
var myAnimatedView = new UIImageView(this.hatchAgeSubView.Bounds);
myAnimatedView.AnimationImages = myImages.ToArray();
myAnimatedView.AnimationDuration = 3; // Seconds
myAnimatedView.AnimationRepeatCount = 4; // 0 = Loops Forever
myAnimatedView.StartAnimating();
hatchAgeSubView.AddSubview(myAnimatedView);
}
如您在上方看到的那样,有一个动画包含两个图像,持续12秒。
我想在12秒后开始另一个动画。 (在以上动画的结尾)
是否有任何回叫方法或是否有使下一个动画自动播放的想法??
最佳答案
如果您使用的是iOS 4或更高版本,则可以使用新的Animate方法,并在第一个动画序列完成时得到通知:
var delay = 0.0f;
UIView.Animate(delay, () => {
UIView.SetAnimationRepeatCount(4);
//Regular animation code goes here.
}, () => {
// This fires when the first animation block above is completed
//Second animation sequence code goes here.
});
更新:请不要从ViewDidLoad调用动画,这会使体验缓慢并且用户不满意。尝试从ViewDidAppear异步调用它。有关“查看事件”的更多信息,请查看我关于该主题的博客文章:
http://blog.devnos.com/uiviewcontroller-y-u-no-fire-view-events
关于iphone - 使用C#在单点触控iPhone项目上的动画 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9556734/