|
@@ -26,8 +26,7 @@ class GalleryGridSectionHeader: UICollectionReusableView {
|
|
|
|
|
|
var text: String? {
|
|
|
set {
|
|
|
- label.text = newValue?.uppercased()
|
|
|
- yAlignLabel(ratio: 0.75)
|
|
|
+ label.text = newValue
|
|
|
}
|
|
|
get {
|
|
|
return label.text
|
|
@@ -52,15 +51,4 @@ class GalleryGridSectionHeader: UICollectionReusableView {
|
|
|
label.leadingAnchor.constraint(equalTo: leadingAnchor, constant: leadingMargin).isActive = true
|
|
|
label.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -leadingMargin).isActive = true
|
|
|
}
|
|
|
-
|
|
|
- /// Can be used to offset the label from center (if there is enough space) - ration == 0.5 will Ycenter the label - ratio >= 0.5 will move the label down.
|
|
|
- private func yAlignLabel(ratio: CGFloat) {
|
|
|
- safe_assert(ratio <= 1)
|
|
|
- let labelHeight = label.intrinsicContentSize.height
|
|
|
- let verticalMarginTotal = frame.height - labelHeight
|
|
|
- if verticalMarginTotal > 0 {
|
|
|
- labelBottomConstraint.constant = verticalMarginTotal * (1 - ratio)
|
|
|
- labelTopConstraint.constant = verticalMarginTotal * ratio
|
|
|
- }
|
|
|
- }
|
|
|
}
|