2019-09-30 15:04:19 -07:00
|
|
|
/*
|
2022-10-04 13:59:32 -07:00
|
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
2017-02-13 09:05:22 -08:00
|
|
|
*
|
2019-10-15 10:30:08 -07:00
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2017-02-13 09:05:22 -08:00
|
|
|
*/
|
|
|
|
|
|
|
|
import UIKit
|
|
|
|
import YogaKit
|
|
|
|
|
|
|
|
final class SingleLabelCollectionCell: UICollectionViewCell {
|
|
|
|
let label: UILabel = UILabel(frame: .zero)
|
|
|
|
|
|
|
|
override init(frame: CGRect) {
|
|
|
|
super.init(frame: frame)
|
|
|
|
|
2017-03-13 12:07:19 -07:00
|
|
|
contentView.configureLayout { (layout) in
|
|
|
|
layout.isEnabled = true
|
|
|
|
layout.flexDirection = .column
|
|
|
|
layout.justifyContent = .flexEnd
|
|
|
|
}
|
2017-02-13 09:05:22 -08:00
|
|
|
|
|
|
|
label.textAlignment = .center
|
|
|
|
label.numberOfLines = 1
|
|
|
|
label.yoga.isIncludedInLayout = false
|
|
|
|
contentView.addSubview(label)
|
|
|
|
|
|
|
|
let border = UIView(frame: .zero)
|
|
|
|
border.backgroundColor = .lightGray
|
2017-03-13 12:07:19 -07:00
|
|
|
border.configureLayout { (layout) in
|
|
|
|
layout.isEnabled = true
|
|
|
|
layout.height = 0.5
|
|
|
|
layout.marginHorizontal = 25
|
|
|
|
}
|
2017-02-13 09:05:22 -08:00
|
|
|
contentView.addSubview(border)
|
|
|
|
}
|
|
|
|
|
|
|
|
required init?(coder aDecoder: NSCoder) {
|
|
|
|
fatalError("init(coder:) has not been implemented")
|
|
|
|
}
|
|
|
|
|
|
|
|
override func layoutSubviews() {
|
|
|
|
super.layoutSubviews()
|
|
|
|
|
|
|
|
contentView.yoga.applyLayout(preservingOrigin: false)
|
|
|
|
label.frame = contentView.bounds
|
|
|
|
}
|
|
|
|
}
|