3
ここ
選択項目Swift 3.0でUICollectionViewCellをズームする方法は? image.Iに示したように、私は選択にハイライトUICollectionViewCellをしようとしています
は、選択したセルに境界線を追加しようとした境界線は、セルコンテンツビュー内できます。ここに私の試しです:
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let cell = priorityCollectionView.cellForItem(at: indexPath) as? BCPriorityListCollectionViewCell
let borderWidth: CGFloat = 6
cell?.contentView.frame = (cell?.labelBackground.frame.insetBy(dx: +borderWidth, dy: +borderWidth))!
cell?.contentView.layer.borderColor = cell?.backgroundColor?.cgColor
cell?.contentView.layer.borderWidth = borderWidth
}
func collectionView(_ collectionView: UICollectionView, didDeselectItemAt indexPath: IndexPath) {
let cell = priorityCollectionView.cellForItem(at: indexPath) as? BCPriorityListCollectionViewCell
let borderWidth: CGFloat = 0
cell?.contentView.frame = (cell?.labelBackground.frame.insetBy(dx: +borderWidth, dy: +borderWidth))!
cell?.contentView.layer.borderColor = UIColor.clear.cgColor
cell?.contentView.layer.borderWidth = borderWidth
}
どのようにこれを行うには?