PopOverViewCell.swift 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. //
  2. // PopOverViewCell.swift
  3. // SwiftBilibili
  4. //
  5. // Created by 罗文 on 2021/2/2.
  6. // Copyright © 2021年 罗文. All rights reserved.
  7. //
  8. import UIKit
  9. class PopOverViewCell: UITableViewCell {
  10. @IBOutlet weak var actionImageView: UIImageView!
  11. @IBOutlet weak var actionTitleLabel: UILabel!
  12. @IBOutlet weak var separatorView: UIView!
  13. @IBOutlet weak var imageViewWidthConstraint: NSLayoutConstraint!
  14. @IBOutlet weak var titleLeftConstraint: NSLayoutConstraint!
  15. var titleLeft: CGFloat = 0
  16. override func awakeFromNib() {
  17. super.awakeFromNib()
  18. titleLeft = titleLeftConstraint.constant
  19. backgroundColor = .white
  20. let backgroundView = UIView()
  21. backgroundView.backgroundColor = UIColor(white: 0.9, alpha: 1.0)
  22. selectedBackgroundView = backgroundView
  23. }
  24. func reloadData(title:String?,image:UIImage?) {
  25. actionTitleLabel.text = title
  26. actionImageView.image = image
  27. titleLeftConstraint.constant = image == nil ? 20 : titleLeft
  28. actionTitleLabel.textAlignment = image == nil ? .center : .left
  29. setNeedsLayout()
  30. }
  31. }