[英]Animate changing the image of a UIImageView
有另一篇文章提到了這個問題,但是沒有一種解決方案有效。 我的問題是我有幾個imageViews需要更改其圖像。 如果我突然更改它們似乎很奇怪,所以我想知道是否有一種方法可以淡入新圖像。
這是當我設置其中一個imageViews時。
self.imageView1.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@.jpg", [images objectAtIndex:newArray[0]]]];
謝謝
imageView的淡入可以通過多種方式實現。 如果您可以發布代碼,(其他人如何能夠在不褪色的情況下立即更改視圖)將建議最簡單的方法
編輯:像下面的代碼一樣嘗試設置alpha動畫:
self.imageView1.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@.jpg", [images objectAtIndex:newArray[0]]]];
self.imgView1.alpha=0;
[UIView animateWithDuration:2.0
delay:0.1
options: UIViewAnimationCurveLinear
animations:^{
self.imgView1.alpha=1;
}
completion:^(BOOL finished){
NSLog(@"Done!");
}];
您可以控制animateWithDuration和delay的值以適合您的應用
讓我們知道是否可行
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.