ios - 选中时 UICollectionView 动画单元格图像
<p><p>我在我的应用中使用 <code>UICollectionView</code> 创建了一个菜单栏。我想在选定的单元格上做动画。现在我只是通过覆盖 <code>collectionViewCell</code> 类中的 <code>isSelected</code> 来更改所选单元格上的图像。我怎样才能在底部的这张图片中制作动画。任何帮助将不胜感激。</p>
<p>我的菜单栏图片:</p>
<p> <a href="/image/puGfb.png" rel="noreferrer noopener nofollow"><img src="/image/puGfb.png" alt="enter image description here"/></a> </p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>假设您想为两个图像之间的过渡设置动画(例如:淡化),当您更改图像时(在您的 <code>isSelected</code> 中),您可以使用以下代码:</p>
<pre><code>UIView.transition(with: self, duration: 0.25, options: UIViewAnimationOptions.transitionCrossDissolve, animations: {
// change the image
}
</code></pre></p>
<p style="font-size: 20px;">关于ios - 选中时 UICollectionView 动画单元格图像,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/47711252/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/47711252/
</a>
</p>
页:
[1]