こんな感じです

コードと簡単解説
- タップしたCellの上に表示するViewの作成
CellOnView
import Foundation
import UIKit
class CellOnView{
let cellOnView = UIView()
}
extension CellOnView{
func createCellOnView(cellPointX:CGFloat,cellPointY:CGFloat,cellWidth:CGFloat,cellHeight:CGFloat,targetView:UIView){
cellOnView.frame = CGRect(x: cellPointX, y: cellPointY, width: cellWidth, height:cellHeight)
cellOnView.backgroundColor = .systemGreen
targetView.addSubview(cellOnView)
}
}
-
cellOnView.createCellOnView(~~~省略~~~,targetView:UIView)
でUIViewを必要としているので,タップしたCellをUIViewとしてselectCellに入れています
ViewController
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let selectCell = collectionView.cellForItem(at: indexPath)! as UIView
cellOnView.createCellOnView(cellPointX: selectCell.bounds.minX, cellPointY: selectCell.bounds.minY, cellWidth: selectCell.frame.size.width, cellHeight: selectCell.frame.size.height, targetView: selectCell)
}
終わり
休憩中に思いつきでやってみたことについて書きました。(役立つかは微妙ですね)
ご指摘や質問などありましたら、喜んで受け付けてます。