【发布时间】:2017-11-20 08:52:37
【问题描述】:
我想在我的根视图控制器中将另一个集合视图 (cellContentCollectionView) 中的矩形转换为相等的矩形。
用于执行此操作的实例方法是 convert(_:to:),但是我无法在根视图控制器框架中设置 UIView 的框架。
这是我目前所拥有的......
cellContentCollectionView?.convert((playerLayer?.frame)!, to: fullScreenPlayerView)
cellContentCollectionView 是它所在的 collectionView。它恰好在 collectionViewCell 中。
有什么建议吗?
【问题讨论】:
-
convert 方法返回一个新的 CGRect 你必须使用它,
let newFrame = cellContentCollectionView?.convert((playerLayer?.frame)!, to: fullScreenPlayerView) -
那么第二个参数 [to View: UIView?] 有什么意义呢?我有点困惑
-
是转换的目标视图,该视图是您需要放置矩形的视图,您需要将
playerLayer?.frame从cellContentCollectionView转换为fullScreenPlayerView坐标系 -
好吧,这是有道理的。当我设置 fullScreenPlayerView.bounds = (newFrame) 时,我仍然遇到问题!我收到错误的指令错误,因为它发现为零。
-
起点和终点两个视图必须在同一个视图树内,否则此方法可以返回 nil
标签: ios swift uiview uicollectionview uicollectionviewcell