123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- //
- // YMGroupChildCollectionCell.swift
- // MvpGoods
- //
- // Created by 小花 on 2019/4/10.
- // Copyright © 2019 MVP. All rights reserved.
- //
- import UIKit
- class YMGroupChildCollectionCell: UICollectionViewCell {
-
- required init?(coder aDecoder: NSCoder) {
- self.init()
- }
-
- override init(frame: CGRect) {
- super.init(frame: frame)
- self.backgroundColor = UIColor.white
- self.layer.cornerRadius = 4
- self.layer.masksToBounds = true
- configSubViews()
- }
-
-
- var model: YMMainGoodModel? {
- didSet {
- imgView.setFadeImage(with: model?.img)
- titleLabel.text = model?.title
- let ticket = model!.coupon_price
- ticketNum.text = "\(ticket ?? 0)"+"元"
- disPrice.text = "¥"+(model?.discount_price ?? "")
- }
- }
-
- func configSubViews() {
- self.contentView.addSubview(imgView)
- self.contentView.addSubview(titleLabel)
- self.contentView.addSubview(ticketBg)
- ticketBg.addSubview(ticketType)
- ticketBg.addSubview(ticketNum)
- self.contentView.addSubview(disPrice)
-
- imgView.snp.makeConstraints { (make) in
- make.top.left.right.equalTo(0)
- make.height.equalTo(imgView.snp.width)
- }
-
- titleLabel.snp.makeConstraints { (make) in
- make.left.equalTo(5)
- make.right.equalTo(-5)
- make.top.equalTo(imgView.snp.bottom).offset(5)
- }
-
- disPrice.snp.makeConstraints { (make) in
- make.left.equalTo(titleLabel)
- make.top.equalTo(titleLabel.snp.bottom).offset(8)
- }
-
- ticketBg.snp.makeConstraints { (make) in
- make.right.equalTo(-10)
- make.centerY.equalTo(disPrice.snp.centerY)
- make.width.equalTo(62*0.7)
- make.height.equalTo(15*0.7)
- }
-
- ticketType.snp.makeConstraints { (make) in
- make.left.top.bottom.equalTo(0)
- make.width.equalTo(20*0.7)
- }
-
- ticketNum.snp.makeConstraints { (make) in
- make.top.right.bottom.equalTo(0)
- make.left.equalTo(20*0.7)
- }
- }
-
- lazy var imgView: UIImageView = {
- let img = UIImageView()
- img.backgroundColor = UIColor.gloadGrayColor()
- return img
- }()
-
- lazy var titleLabel: UILabel = {
- let title = UILabel()
- title.textColor = UIColor.hexadecimalColor(hexadecimal: "#262626")
- title.font = UIFont.boldSystemFont(ofSize: 15)
- title.numberOfLines = 1
-
- return title
- }()
-
-
- lazy var ticketBg: UIImageView = {
- let ticket = UIImageView()
- ticket.image = UIImage(named: "ticketBg")
- return ticket;
- }()
-
- lazy var ticketType: UILabel = {
- let type = UILabel()
- type.textColor = UIColor.white
- type.font = UIFont.systemFont(ofSize: 9)
- type.textAlignment = NSTextAlignment.center
- type.text = "券"
- return type
- }()
-
- lazy var ticketNum: UILabel = {
- let num = UILabel()
- num.textColor = UIColor.white
- num.font = UIFont.systemFont(ofSize: 9)
- num.textAlignment = NSTextAlignment.center
- return num
- }()
-
- lazy var disPrice: UILabel = {
- let dis = UILabel()
- dis.textColor = UIColor.gloadRedColor()
- dis.font = UIFont.systemFont(ofSize: 9)
-
- return dis
- }()
-
- }
|