Skip to content

Instantly share code, notes, and snippets.

@jimmythai
Created September 5, 2019 07:49
Show Gist options
  • Save jimmythai/e49997d589be5a3be21834632c025a48 to your computer and use it in GitHub Desktop.
Save jimmythai/e49997d589be5a3be21834632c025a48 to your computer and use it in GitHub Desktop.
// Cell
final class CircleCell: UICollectionViewCell {
@IBOutlet private weak var circleView: UIView!
func setCircleView() {
layoutIfNeeded() // Without this, it doesn't draw a circle correctly.
circleView.layer.cornerRadius = circleView.frame.width / 2
}
}
// DataSouce
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell...
cell.setCircleView()
return cell
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment