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
}
如何做到這一點?