123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- //
- // MessageOneCollectionViewCell.swift
- // RainbowPlanet
- //
- // Created by 南鑫林 on 2019/4/24.
- // Copyright © 2019 南鑫林. All rights reserved.
- //
- import UIKit
- class MessageOneCollectionViewCell: UICollectionViewCell {
- class func cellWith(collectionView:UICollectionView,indexPath:IndexPath) -> MessageOneCollectionViewCell {
- let ID = "MessageOneCollectionViewCell"
- collectionView.register(MessageOneCollectionViewCell.self, forCellWithReuseIdentifier: ID)
- let cell : MessageOneCollectionViewCell = collectionView.dequeueReusableCell(withReuseIdentifier: ID, for: indexPath) as! MessageOneCollectionViewCell
- cell.indexPath = indexPath
- return cell
- }
- //MARK: - indexPath
- var indexPath: IndexPath?{
- didSet {
-
- }
- }
- //MARK: - 初始化
- override init(frame: CGRect) {
- super.init(frame: frame)
- setupViews()
- setupLayouts()
- }
-
- required init?(coder aDecoder: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
-
- //MARK: - 设置view
- private func setupViews() {
- backgroundColor = .white
- addSubview(iconButton)
- }
-
- private func setupLayouts() {
- iconButton.snp.makeConstraints { (make) in
- make.top.equalTo(22)
- make.centerX.equalToSuperview()
- make.width.equalTo(kScreenWidth/3)
- make.height.equalTo(kScaleValue(value: 40)+24)
- }
- }
-
- private lazy var iconButton: UIButton = {
- let iconButton = UIButton(type: UIButton.ButtonType.custom)
- iconButton.setTitleColor(k333333Color, for: UIControl.State.normal)
- iconButton.titleLabel?.font = kMediumFont15
- iconButton.titleLabel?.adjustsFontSizeToFitWidth = true
- iconButton.isUserInteractionEnabled = false
- return iconButton
- }()
-
- func setCell(titles:Array<String>,images:Array<String>) {
- iconButton.setImage(kImage(name: images[(indexPath?.row)!]), for: UIControl.State.normal)
- iconButton.setTitle(titles[(indexPath?.row)!], for: UIControl.State.normal)
- iconButton.layoutButton(edgeInsetsStyle: ButtonEdgeInsetsStyle.top, imageTitleSpace: 6)
- }
- }
|