【发布时间】:2017-08-07 21:30:54
【问题描述】:
我的 ReusableCollectionView 中有一个圆形的 Imageview。 当我向下滚动我的 collectionView 时,我会缩放我的 Imageview,一旦它滚动回原位,我就会将其缩放到原始大小。
func scrollViewDidScroll(_ scrollView: UIScrollView) {
// Exit early if swiping up (scrolling down)
if scrollView.contentOffset.y > 0 { return }
// this is just a demo method on how to compute the scale factor based on the current contentOffset
var scale = 1.0 + fabs(scrollView.contentOffset.y) / scrollView.frame.size.height
//Cap the scaling between zero and 1
scale = max(0.0, scale)
// Set the scale to the imageView
headerView.imageview.transform = CGAffineTransform(scaleX: scale, y: scale)
headerView.categoryButton.transform = CGAffineTransform(scaleX: scale, y: scale)
}
这样做时,图像视图不再是圆形的。
这是一个可视化问题的图像:
【问题讨论】:
标签: ios swift uiimageview uicollectionview