优惠券swift版马甲包

YMGroupChildCollectionCell.swift 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. //
  2. // YMGroupChildCollectionCell.swift
  3. // MvpGoods
  4. //
  5. // Created by 小花 on 2019/4/10.
  6. // Copyright © 2019 MVP. All rights reserved.
  7. //
  8. import UIKit
  9. class YMGroupChildCollectionCell: UICollectionViewCell {
  10. required init?(coder aDecoder: NSCoder) {
  11. self.init()
  12. }
  13. override init(frame: CGRect) {
  14. super.init(frame: frame)
  15. self.backgroundColor = UIColor.white
  16. self.layer.cornerRadius = 4
  17. self.layer.masksToBounds = true
  18. configSubViews()
  19. }
  20. var model: YMMainGoodModel? {
  21. didSet {
  22. imgView.setFadeImage(with: model?.img)
  23. titleLabel.text = model?.title
  24. let ticket = model!.coupon_price
  25. ticketNum.text = "\(ticket ?? 0)"+"元"
  26. disPrice.text = "¥"+(model?.discount_price ?? "")
  27. }
  28. }
  29. func configSubViews() {
  30. self.contentView.addSubview(imgView)
  31. self.contentView.addSubview(titleLabel)
  32. self.contentView.addSubview(ticketBg)
  33. ticketBg.addSubview(ticketType)
  34. ticketBg.addSubview(ticketNum)
  35. self.contentView.addSubview(disPrice)
  36. imgView.snp.makeConstraints { (make) in
  37. make.top.left.right.equalTo(0)
  38. make.height.equalTo(imgView.snp.width)
  39. }
  40. titleLabel.snp.makeConstraints { (make) in
  41. make.left.equalTo(5)
  42. make.right.equalTo(-5)
  43. make.top.equalTo(imgView.snp.bottom).offset(5)
  44. }
  45. disPrice.snp.makeConstraints { (make) in
  46. make.left.equalTo(titleLabel)
  47. make.top.equalTo(titleLabel.snp.bottom).offset(8)
  48. }
  49. ticketBg.snp.makeConstraints { (make) in
  50. make.right.equalTo(-10)
  51. make.centerY.equalTo(disPrice.snp.centerY)
  52. make.width.equalTo(62*0.7)
  53. make.height.equalTo(15*0.7)
  54. }
  55. ticketType.snp.makeConstraints { (make) in
  56. make.left.top.bottom.equalTo(0)
  57. make.width.equalTo(20*0.7)
  58. }
  59. ticketNum.snp.makeConstraints { (make) in
  60. make.top.right.bottom.equalTo(0)
  61. make.left.equalTo(20*0.7)
  62. }
  63. }
  64. lazy var imgView: UIImageView = {
  65. let img = UIImageView()
  66. img.backgroundColor = UIColor.gloadGrayColor()
  67. return img
  68. }()
  69. lazy var titleLabel: UILabel = {
  70. let title = UILabel()
  71. title.textColor = UIColor.hexadecimalColor(hexadecimal: "#262626")
  72. title.font = UIFont.boldSystemFont(ofSize: 15)
  73. title.numberOfLines = 1
  74. return title
  75. }()
  76. lazy var ticketBg: UIImageView = {
  77. let ticket = UIImageView()
  78. ticket.image = UIImage(named: "ticketBg")
  79. return ticket;
  80. }()
  81. lazy var ticketType: UILabel = {
  82. let type = UILabel()
  83. type.textColor = UIColor.white
  84. type.font = UIFont.systemFont(ofSize: 9)
  85. type.textAlignment = NSTextAlignment.center
  86. type.text = "券"
  87. return type
  88. }()
  89. lazy var ticketNum: UILabel = {
  90. let num = UILabel()
  91. num.textColor = UIColor.white
  92. num.font = UIFont.systemFont(ofSize: 9)
  93. num.textAlignment = NSTextAlignment.center
  94. return num
  95. }()
  96. lazy var disPrice: UILabel = {
  97. let dis = UILabel()
  98. dis.textColor = UIColor.gloadRedColor()
  99. dis.font = UIFont.systemFont(ofSize: 9)
  100. return dis
  101. }()
  102. }