Reputation:
I have a round Imageview in my ReusableCollectionView. When I scroll down my collectionView I scale my Imageview and as soon as it scrolls back to place I scale it to its original size.
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)
}
The imageview is not round anymore while doing so.
Here is an image visualising the problem:
Upvotes: 2
Views: 222
Reputation:
This is how I solved the problem:
imageView.autoresizesSubviews = false
Upvotes: 1