-
Notifications
You must be signed in to change notification settings - Fork 234
Expand file tree
/
Copy pathMyColorSquareCell.swift
More file actions
33 lines (30 loc) · 979 Bytes
/
MyColorSquareCell.swift
File metadata and controls
33 lines (30 loc) · 979 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//
// MyColorSquareCell.swift
// ReusableDemo
//
// Created by Olivier Halligon on 19/01/2016.
// Copyright © 2016 AliSoftware. All rights reserved.
//
import UIKit
import Reusable
/**
* This view is reusable and has a `reuseIdentifier` (as it's a CollectionViewCell
* and it uses the Collectioniew recycling mechanism).
*
* That's why it's annotated with the `Reusable` protocol.
*
* This view is NOT loaded from a NIB (but defined entierly by code),
* that's why it's not annotated as `NibLoadable` but only `Reusable`
*/
final class MyColorSquareCell: UICollectionViewCell, Reusable, AutoRegistering {
private lazy var colorView: UIView = {
let colorView = UIView()
colorView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
colorView.frame = self.contentView.bounds.insetBy(dx: 10, dy: 10)
self.contentView.addSubview(colorView)
return colorView
}()
func fill(_ color: UIColor) {
self.colorView.backgroundColor = color
}
}