2021-01-30 23:27:49 +01:00
|
|
|
// Copyright © 2021 Metabolist. All rights reserved.
|
|
|
|
|
|
|
|
import UIKit
|
|
|
|
|
|
|
|
final class ExploreSectionHeaderView: UICollectionReusableView {
|
|
|
|
let label = UILabel()
|
|
|
|
|
|
|
|
override init(frame: CGRect) {
|
|
|
|
super.init(frame: frame)
|
|
|
|
|
|
|
|
initialSetup()
|
|
|
|
}
|
|
|
|
|
|
|
|
@available(*, unavailable)
|
|
|
|
required init?(coder: NSCoder) {
|
|
|
|
fatalError("init(coder:) has not been implemented")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private extension ExploreSectionHeaderView {
|
|
|
|
func initialSetup() {
|
|
|
|
backgroundColor = .systemBackground
|
|
|
|
|
|
|
|
addSubview(label)
|
|
|
|
label.translatesAutoresizingMaskIntoConstraints = false
|
|
|
|
label.adjustsFontForContentSizeCategory = true
|
|
|
|
label.font = .preferredFont(forTextStyle: .headline)
|
2021-01-31 06:43:40 +01:00
|
|
|
label.textColor = .secondaryLabel
|
2021-01-30 23:27:49 +01:00
|
|
|
|
2021-01-31 06:43:40 +01:00
|
|
|
let leadingConstraint: NSLayoutConstraint
|
2021-01-30 23:27:49 +01:00
|
|
|
|
|
|
|
if UIDevice.current.userInterfaceIdiom == .pad {
|
2021-01-31 06:43:40 +01:00
|
|
|
leadingConstraint = label.leadingAnchor.constraint(equalToSystemSpacingAfter: leadingAnchor, multiplier: 1)
|
2021-01-30 23:27:49 +01:00
|
|
|
} else {
|
2021-01-31 06:43:40 +01:00
|
|
|
leadingConstraint = label.leadingAnchor.constraint(equalTo: layoutMarginsGuide.leadingAnchor)
|
2021-01-30 23:27:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
NSLayoutConstraint.activate([
|
2021-01-31 06:43:40 +01:00
|
|
|
leadingConstraint,
|
|
|
|
label.topAnchor.constraint(equalTo: layoutMarginsGuide.topAnchor),
|
|
|
|
label.trailingAnchor.constraint(equalTo: layoutMarginsGuide.trailingAnchor),
|
|
|
|
label.bottomAnchor.constraint(equalTo: layoutMarginsGuide.bottomAnchor)
|
2021-01-30 23:27:49 +01:00
|
|
|
])
|
|
|
|
}
|
|
|
|
}
|