【问题标题】:UICollectionViewLayoutAttributes and transformUICollectionViewLayoutAttributes 和变换
【发布时间】:2020-06-15 06:31:09
【问题描述】:

我正在使用以下来修改 UICollectionViewLayoutAttributes。方法一有效,方法二无效,谁能帮忙解释一下区别?

guard let newAttrs = attributes?.copy() as? UICollectionViewLayoutAttributes, 
      let imageViewInfo = imageViewInfo else { return nil }

let center = imageViewInfo.center

//Method 1
newAttrs.transform = CGAffineTransform(scaleX: scale, y: scale)
let x = (newAttrs.center.x-center.x) * scale + igCenter.x
let y = (newAttrs.center.y-center.y) * scale + igCenter.y
newAttrs.center = CGPoint(x: x, y: y)

//Method 2
newAttrs.transform = CGAffineTransform(translationX: -center.x, y: -center.y)
  .scaledBy(x: scale, y: scale)
  .translatedBy(x: igCenter.x, y: igCenter.y)

【问题讨论】:

    标签: ios swift uicollectionview transform uicollectionviewlayout


    【解决方案1】:

    https://developer.apple.com/documentation/uikit/uiview/1622459-transform

    要更改视图/单元格的位置,请改为修改“中心”。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-09-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-13
      相关资源
      最近更新 更多