IGListKit/Examples/Examples-iOS/IGListKitExamples/Views/LoadingCell.swift

45 lines
1.2 KiB
Swift
Raw Normal View History

/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import UIKit
final class LoadingCell: UICollectionViewCell {
private let activityIndicator: UIActivityIndicatorView = {
let indicator = UIActivityIndicatorView(style: .medium)
indicator.translatesAutoresizingMaskIntoConstraints = false
indicator.color = .darkGray
indicator.hidesWhenStopped = false
return indicator
}()
override init(frame: CGRect) {
super.init(frame: frame)
setupViews()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
private func setupViews() {
contentView.addSubview(activityIndicator)
NSLayoutConstraint.activate([
activityIndicator.centerXAnchor.constraint(equalTo: contentView.centerXAnchor),
activityIndicator.centerYAnchor.constraint(equalTo: contentView.centerYAnchor)
])
activityIndicator.startAnimating()
}
override func prepareForReuse() {
super.prepareForReuse()
activityIndicator.startAnimating()
}
}