[CM-902] Add border color to colorView
This commit is contained in:
parent
4d8b7ec054
commit
b89e530dfd
|
@ -34,7 +34,7 @@ Documentation is automatically generated from source code comments and rendered
|
|||
|
||||
Usage
|
||||
----------
|
||||
A category is a collection of components that share common traits. A category may contain subcategories. By default, components are laid out in nested table views, with each component being represented by a single row. A `CatalogDisplayView` is used to display a component in a single row. It displays small components together with a title and optional detail description. This is used for icons, fonts, and colors, but also works well for smaller components such as buttons. By using generics, `CaralogDisplayView` can display any view (populated with an associated model). The framework includes pre-defined categories for displaying common components: colors, fonts, and icons.
|
||||
A category is a collection of components that share common traits. A category may contain subcategories. By default, components are laid out in nested table views, with each component being represented by a single row. A `CatalogDisplayView` is used to display a component in a single row. It displays small components together with a title and optional detail description. This is used for icons, fonts, and colors, but also works well for smaller components such as buttons. By using generics, `CatalogDisplayView` can display any view (populated with an associated model). The framework includes pre-defined categories for displaying common components: colors, fonts, and icons.
|
||||
|
||||
The catalog display view model has four parameters:
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import Foundation
|
||||
|
||||
/// Category for colours
|
||||
/// Category for colors
|
||||
public struct ColorCategory: Classification {
|
||||
/// The type of View category supports
|
||||
public typealias View = CatalogDisplayView<ColorView>
|
||||
|
|
|
@ -26,15 +26,30 @@ final public class ColorView: UIView {
|
|||
/// :nodoc:
|
||||
public required init?(coder: NSCoder) { nil }
|
||||
|
||||
/// :nodoc:
|
||||
public override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
|
||||
super.traitCollectionDidChange(previousTraitCollection)
|
||||
if traitCollection.hasDifferentColorAppearance(comparedTo: previousTraitCollection) {
|
||||
setBorderColor()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private extension ColorView {
|
||||
private func setUpColorView() {
|
||||
clipsToBounds = true
|
||||
layer.cornerRadius = Style.cornerRadius
|
||||
|
||||
layer.borderWidth = Style.borderWidth
|
||||
setBorderColor()
|
||||
NSLayoutConstraint.activate([
|
||||
widthAnchor.constraint(equalToConstant: Style.size.width),
|
||||
heightAnchor.constraint(equalToConstant: Style.size.height)
|
||||
])
|
||||
}
|
||||
|
||||
private func setBorderColor() {
|
||||
layer.borderColor = UIColor.quaternaryLabel.cgColor
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Populatable
|
||||
|
|
Loading…
Reference in New Issue