SNo*_*Nos 5 ios uicollectionview swift2
UICollectionView我的视图控制器中有一个。它已经设置并且工作正常。
当单元格本身内部的按钮被按下时,我试图缩放单元格。
我的代码缩放了单元格,但是,我找不到强制所选单元格转到其他单元格前面的方法。现在,单元格选择它总是在选择之前的单元格后面。
如何强制所选单元格在其他单元格前面缩放?
@IBAction func detailBtnAction(sender:UIButton){
let indexUser = (sender.layer.valueForKey("indexBtn")) as! Int
let indexPath = NSIndexPath(forItem: indexUser, inSection: 0)
let feedCell = feedCollectionView.cellForItemAtIndexPath(indexPath)
feedCell?.bringSubviewToFront(feedCollectionView)
feedCell?.contentView.bringSubviewToFront(feedCollectionView)
UIView.animateWithDuration(1.0) { () -> Void in
feedCell?.transform = CGAffineTransformMakeScale(5, 5)
}
}
Run Code Online (Sandbox Code Playgroud)
看来你把事情的顺序搞混了一点。
来自文档:
移动指定的子视图,使其显示在其同级视图的上方。
func BringSubviewToFront(_ view: UIView)
参数
view - 要移动到前面的子视图。
此方法将指定视图移动到 subviews 属性中视图数组的末尾。
所以你的电话:
feedCell?.contentView.bringSubviewToFront(feedCollectionView)
实际上意味着单元格内容视图应该移动feedCollectionView到前面。
现在,这是基于命名的一些有根据的猜测,但它应该看起来像这样:
feedCollectionView.bringSubviewToFront(feedCell?)
您可以将单元格本身传递到那里,因为它继承自UIView.
| 归档时间: |
|
| 查看次数: |
3313 次 |
| 最近记录: |