ios - Xamarin iOS 图像更改过渡
<p><p>我正在使用 Xamarin.IOS 开发应用程序,但我没有使用 Xamarin.Forms。<br/>
我有一个设置了 ImageView 的屏幕。<br/>
现在我想在带有过渡的 2/3/4 图像之间进行切换(淡入淡出,移入……没关系)。<br/>
有什么办法可以做到吗?<br/>
到目前为止,这是我的代码:</p>
<pre><code> imgView.AnimationImages = new UIImage[] {
UIImage.FromBundle ("tmp_running.jpg")
, UIImage.FromBundle ("tmp_cycling.jpg")
} ;
imgView.AnimationRepeatCount = 0;
imgView.AnimationDuration = 3;
imgView.StartAnimating ();
</code></pre>
<p>我已经尝试过这种方法:</p>
<pre><code> CATransition customTransition = new CATransition();
customTransition.FadeInDuration = 3.0f;
customTransition.FadeOutDuration = 3.0f;
customTransition.TimingFunction = CAMediaTimingFunction.FromName(
CAMediaTimingFunction.EaseInEaseOut);
customTransition.Type = CATransition.TransitionFade;
and then :
imgView.Layer.AddAnimation(customTransition, null);
</code></pre>
<p>但没有任何效果。</p>
<p>你知道怎么做这个简单的任务吗?</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>可以这样做:</p>
<pre><code> static int count = 0;
UIImageView _imageView;
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
_imageView = new UIImageView (new CGRect(0, 0, 100, 100));
_imageView.Image = new UIImage ("1.png");
Add (_imageView);
animateImage ();
}
public void animateImage()
{
var animationImages = new List<UIImage> () {
UIImage.FromFile ("1.png"),
UIImage.FromFile ("2.png"),
UIImage.FromFile ("3.png"),
UIImage.FromFile ("4.png"),
UIImage.FromFile ("5.png")};
UIImage image = animationImages;
UIView.Transition (_imageView, 3.0,
UIViewAnimationOptions.TransitionCrossDissolve,
() => {_imageView.Image = image;},
() => { animateImage ();
count++; }
);
}
</code></pre></p>
<p style="font-size: 20px;">关于ios - Xamarin iOS 图像更改过渡,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/32299807/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/32299807/
</a>
</p>
页:
[1]