ios - CollectionViewCell 效果
问题描述
有什么想法,如何从新的 Shortcuts 应用程序中为 collectionViewCells应用这种很酷的效果?
解决方案
您可以在 uiCollectionViewCell 类中简单地添加以下代码,并在 uiCollectionView 中查看效果。
class imgcollectioncell: UICollectionViewCell {
@IBOutlet weak var img: UIImageView!
override var isHighlighted: Bool{
didSet{
if isHighlighted{
UIView.animate(withDuration: 0.5, delay: 0.0, usingSpringWithDamping: 0.5, initialSpringVelocity: 1.0, options: .curveEaseOut, animations: {
self.transform = self.transform.scaledBy(x: 0.75, y: 0.75)
}, completion: nil)
}else{
UIView.animate(withDuration: 0.5, delay: 0.0, usingSpringWithDamping: 0.4, initialSpringVelocity: 1.0, options: .curveEaseOut, animations: {
self.transform = CGAffineTransform.identity.scaledBy(x: 1.0, y: 1.0)
}, completion: nil)
}
}
}
}
我希望它会帮助你。
推荐阅读
- reactjs - Nav.Link to="/About" 在 react-bootstrap 中不起作用?Nav.Link href="/About 正在重新加载整个页面
- vb.net - vb.NET 使用 vb 类而不是表单启动表单,但表单一开始就关闭
- python - Tkinter 初学者
- regex - 正则表达式 - 创建
- python - 从带有请求的 url 中获取随机行
- python - 如何使用 Python 从文本文件中自动删除特定字符?
- python-3.x - 如何在python中调用方法作为命令参数
- azure - 如何将用户添加到 Azure Devops
- r - R:如何删除列表中的特定条目
- azure - Azure 日志分析的灾难恢复/故障转移