BFThumImageView.swift 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. //
  2. // BFThumImageView.swift
  3. // BFRecordScreenKit
  4. //
  5. // Created by 胡志强 on 2022/2/9.
  6. //
  7. import Foundation
  8. import UIKit
  9. class BFThumImageView: UIView {
  10. var isHiddenBord = false{
  11. didSet{
  12. if let v = self.viewWithTag(12333){
  13. v.isHidden = isHiddenBord
  14. }
  15. }
  16. }
  17. fileprivate let iv : UIImageView = {
  18. let iv = UIImageView()
  19. iv.frame = CGRect(x: 0, y: 0, width: 70, height: 50)
  20. iv.contentMode = .scaleAspectFill
  21. return iv
  22. }()
  23. var image: UIImage? {
  24. didSet{
  25. iv.image = image
  26. }
  27. }
  28. override init(frame: CGRect) {
  29. super.init(frame: frame)
  30. addIndicationView()
  31. }
  32. required init?(coder: NSCoder) {
  33. fatalError("init(coder:) has not been implemented")
  34. }
  35. init(image: UIImage?) {
  36. super.init(frame: CGRect.zero)
  37. self.image = image
  38. self.clipsToBounds = true
  39. addIndicationView()
  40. }
  41. func addIndicationView(){
  42. subviews.forEach { v in
  43. v.removeFromSuperview()
  44. }
  45. addSubview(iv)
  46. let bottomView = UIView()
  47. bottomView.backgroundColor = ThemeStyleColor
  48. addSubview(bottomView)
  49. bottomView.snp.makeConstraints { make in
  50. make.left.bottom.width.equalToSuperview()
  51. make.height.equalTo(6)
  52. }
  53. let line = UIView()
  54. line.backgroundColor = UIColor.init(white: 0, alpha: 0.5)
  55. line.tag = 12333
  56. addSubview(line)
  57. line.snp.makeConstraints { make in
  58. make.right.top.bottom.equalToSuperview()
  59. make.width.equalTo(1.5)
  60. }
  61. }
  62. }