【问题标题】:Swift 3 - Scale round ImageViewSwift 3 - 缩放圆形 ImageView
【发布时间】: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


    【解决方案1】:

    这就是我解决问题的方法:

    imageView.autoresizesSubviews = false
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-21
      • 1970-01-01
      • 2020-05-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多