Tusker/Tusker/Views/Asset Picker/AssetPickerControlCollectio...

48 lines
1.4 KiB
Swift

//
// AssetPickerControlCollectionViewCell.swift
// Tusker
//
// Created by Shadowfacts on 1/21/22.
// Copyright © 2022 Shadowfacts. All rights reserved.
//
import UIKit
class AssetPickerControlCollectionViewCell: UICollectionViewCell {
let imageView = UIImageView()
let label = UILabel()
override init(frame: CGRect) {
super.init(frame: frame)
imageView.contentMode = .scaleAspectFit
imageView.setContentHuggingPriority(.defaultLow, for: .vertical)
label.font = .preferredFont(forTextStyle: .caption1)
label.textAlignment = .center
let stackView = UIStackView(arrangedSubviews: [
imageView,
label,
])
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.axis = .vertical
stackView.alignment = .center
addSubview(stackView)
NSLayoutConstraint.activate([
stackView.leadingAnchor.constraint(equalTo: leadingAnchor),
stackView.trailingAnchor.constraint(equalTo: trailingAnchor),
stackView.topAnchor.constraint(equalTo: topAnchor, constant: 8),
stackView.bottomAnchor.constraint(equalTo: bottomAnchor, constant: -8),
imageView.widthAnchor.constraint(equalTo: widthAnchor, constant: -32)
])
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}