CommonDataView.swift 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. //
  2. // CommonDataView.swift
  3. // xingchuangke
  4. //
  5. // Created by 李晓飞 on 2020/8/13.
  6. // Copyright © 2020 Virgil. All rights reserved.
  7. //
  8. import UIKit
  9. class CommonDataView: UIView {
  10. lazy var bgImgV: UIImageView = {
  11. let imgV = UIImageView.init(image: UIImage(named: "img_card_banner_07"))
  12. imgV.isUserInteractionEnabled = true
  13. return imgV
  14. }()
  15. lazy var earnTitLbl: UILabel = {
  16. let lbl = UILabel.init()
  17. lbl.text = "总额"
  18. lbl.textColor = UIColor.white
  19. return lbl
  20. }()
  21. lazy var earnLbl: UILabel = {
  22. let lbl = UILabel.init()
  23. lbl.text = "0.00"
  24. lbl.textColor = UIColor.white
  25. return lbl
  26. }()
  27. lazy var rewardTitLbl: UILabel = {
  28. let lbl = UILabel.init()
  29. lbl.text = "奖励"
  30. lbl.textColor = UIColor.white
  31. lbl.textAlignment = .right
  32. return lbl
  33. }()
  34. lazy var rewardLbl: UILabel = {
  35. let lbl = UILabel.init()
  36. lbl.text = "0.00"
  37. lbl.textColor = UIColor.white
  38. lbl.textAlignment = .right
  39. return lbl
  40. }()
  41. lazy var rewardControl: UIControl = {
  42. let btn = UIControl.init()
  43. btn.isUserInteractionEnabled = true
  44. return btn
  45. }()
  46. override init(frame: CGRect) {
  47. super.init(frame: frame)
  48. setupUI()
  49. }
  50. required init?(coder: NSCoder) {
  51. fatalError("init(coder:) has not been implemented")
  52. }
  53. func setupUI() {
  54. self.addSubview(bgImgV)
  55. bgImgV.addSubview(earnTitLbl)
  56. bgImgV.addSubview(earnLbl)
  57. bgImgV.addSubview(rewardTitLbl)
  58. bgImgV.addSubview(rewardLbl)
  59. bgImgV.addSubview(rewardControl)
  60. let w = self.frame.width
  61. let h = self.frame.height
  62. bgImgV.setOrigin(x: 0, y: 0)
  63. bgImgV.setSize(width: w, height: h)
  64. bgImgV.layer.cornerRadius = 10
  65. bgImgV.layer.masksToBounds = true
  66. earnTitLbl.setOrigin(x: 20, y: 50)
  67. earnTitLbl.setSizeHeight(height: 30)
  68. earnTitLbl.setSizeWidth(width: 150)
  69. earnLbl.setOrigin(x: 20, y: 80)
  70. earnLbl.setSizeHeight(height: 30)
  71. earnLbl.setSizeWidth(width: 150)
  72. rewardTitLbl.setOrigin(x: w - 170, y: 50)
  73. rewardTitLbl.setSizeHeight(height: 30)
  74. rewardTitLbl.setSizeWidth(width: 150)
  75. rewardLbl.setOrigin(x: w - 170, y: 80)
  76. rewardLbl.setSizeHeight(height: 30)
  77. rewardLbl.setSizeWidth(width: 150)
  78. rewardControl.setOrigin(x: 0, y: 0)
  79. rewardControl.setSize(width: w, height: h)
  80. }
  81. /*
  82. // Only override draw() if you perform custom drawing.
  83. // An empty implementation adversely affects performance during animation.
  84. override func draw(_ rect: CGRect) {
  85. // Drawing code
  86. }
  87. */
  88. }