OneSectionTableViewCell.m 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. //
  2. // OneSectionTableViewCell.m
  3. // BuguLive
  4. //
  5. // Created by fanwe2014 on 16/8/5.
  6. // Copyright © 2016年 xfg. All rights reserved.
  7. #import "OneSectionTableViewCell.h"
  8. #import "AcutionDetailModel.h"
  9. @implementation OneSectionTableViewCell
  10. - (void)awakeFromNib
  11. {
  12. [super awakeFromNib];
  13. //设定时分秒的背景
  14. self.auctionButton.layer.cornerRadius = self.auctionButton.frame.size.height/2;
  15. self.backgroundColor = kAppMainColor;
  16. self.timeLabel.textColor = self.maoHaoLabel2.textColor = self.maoHaoLabel.textColor = kAppGrayColor1;
  17. self.minuteLabel.textColor = self.secLabel.textColor = self.hourLabel.textColor = kWhiteColor;
  18. self.auctionButton = [UIButton buttonWithType:UIButtonTypeCustom];
  19. self.auctionButton.titleLabel.font = [UIFont systemFontOfSize:12];
  20. [self.auctionButton setTitle:ASLocalizedString(@"竞拍结束")forState:0];
  21. [self addSubview:self.auctionButton];
  22. }
  23. - (void)creatCellWithArray:(NSMutableArray *)array andStatue:(int)statue
  24. {
  25. AcutionDetailModel *ADModel = array[0];
  26. if (statue == 0)//0竞拍中 1竞拍成功 2流拍 3失败
  27. {
  28. self.auctionImgView.hidden = YES;
  29. self.auctionButton.hidden = YES;
  30. self.auctionLabel.hidden = YES;
  31. self.rightImgView.hidden = NO;
  32. self.priceLabel.hidden = NO;
  33. self.timeLabel.hidden = NO;
  34. self.hourLabel.hidden = NO;
  35. self.minuteLabel.hidden = NO;
  36. self.secLabel.hidden = NO;
  37. self.goldImgView.hidden = NO;
  38. self.nowPriceLabel.hidden = NO;
  39. self.remainTimeLabel.hidden = NO;
  40. self.maoHaoLabel.hidden = NO;
  41. self.maoHaoLabel2.hidden = NO;
  42. self.priceLabel.text = ADModel.info.last_pai_diamonds;
  43. }else
  44. {
  45. self.auctionImgView.hidden = NO;
  46. self.auctionButton.hidden = NO;
  47. self.auctionLabel.hidden = NO;
  48. self.rightImgView.hidden = YES;
  49. self.priceLabel.hidden = YES;
  50. self.timeLabel.hidden = YES;
  51. self.hourLabel.hidden = YES;
  52. self.minuteLabel.hidden = YES;
  53. self.secLabel.hidden = YES;
  54. self.goldImgView.hidden = YES;
  55. self.nowPriceLabel.hidden = YES;
  56. self.remainTimeLabel.hidden = YES;
  57. self.maoHaoLabel.hidden = YES;
  58. self.maoHaoLabel2.hidden = YES;
  59. if (statue == 1)
  60. {
  61. self.backImgView.backgroundColor = kAppMainColor;
  62. self.auctionImgView.image = [UIImage imageNamed:@"ac_success"];
  63. NSString *string = ASLocalizedString(@"竞拍成功");
  64. NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:string];
  65. [attr setAttributes:@{NSFontAttributeName : [UIFont systemFontOfSize:20.0]} range:NSMakeRange(0, string.length)];
  66. CGFloat width =[string sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:20]}].width;
  67. self.auctionLabel.frame = CGRectMake(self.auctionImgView.frame.size.width+self.auctionImgView.frame.origin.x+5,16,width, 20);
  68. self.auctionLabel.attributedText = attr;
  69. self.auctionButton.frame = CGRectMake(self.auctionLabel.frame.size.width+self.auctionLabel.frame.origin.x+5,16,65 ,20);
  70. self.auctionButton.backgroundColor = kYellowColor;
  71. [self.auctionButton setTitleColor:kAppMainColor forState:0];
  72. [self.auctionButton setTitle:ASLocalizedString(@"结算中")forState:0];
  73. }else if (statue == 2)
  74. {
  75. self.backImgView.backgroundColor = kAppGrayColor6;
  76. self.auctionImgView.image = [UIImage imageNamed:@"ac_fail"];
  77. NSString *string = ASLocalizedString(@"流拍");
  78. NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:string];
  79. [attr setAttributes:@{NSFontAttributeName : [UIFont systemFontOfSize:20.0]} range:NSMakeRange(0, string.length)];
  80. CGFloat width =[string sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:20]}].width;
  81. self.auctionLabel.frame = CGRectMake(self.auctionImgView.frame.size.width+self.auctionImgView.frame.origin.x+5,16,width, 20);
  82. self.auctionLabel.attributedText = attr;
  83. CGRect rect = self.auctionButton.frame;
  84. rect = CGRectMake(self.auctionLabel.frame.size.width+self.auctionLabel.frame.origin.x+5,16,65 ,20);
  85. self.auctionButton.frame = rect;
  86. self.auctionButton.backgroundColor = kAppGrayColor7;
  87. [self.auctionButton setTitleColor:kWhiteColor forState:0];
  88. }else if (statue == 3)
  89. {
  90. self.backImgView.backgroundColor = kAppGrayColor6;
  91. self.auctionImgView.image = [UIImage imageNamed:@"ac_fail"];
  92. NSString *string = ASLocalizedString(@"竞拍失败");
  93. NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:string];
  94. [attr setAttributes:@{NSFontAttributeName : [UIFont systemFontOfSize:20.0]} range:NSMakeRange(0, string.length)];
  95. CGFloat width =[string sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:20]}].width;
  96. self.auctionLabel.frame = CGRectMake(self.auctionImgView.frame.size.width+self.auctionImgView.frame.origin.x+5,16,width, 20);
  97. self.auctionLabel.attributedText = attr;
  98. self.auctionButton.frame = CGRectMake(self.auctionLabel.frame.size.width+self.auctionLabel.frame.origin.x+5,16,90 ,20);
  99. [self.auctionButton setTitle:ASLocalizedString(@"主播关闭竞拍")forState:0];
  100. self.auctionButton.backgroundColor = kAppGrayColor7;
  101. [self.auctionButton setTitleColor:kWhiteColor forState:0];
  102. }else if (statue == 4)
  103. {
  104. self.backImgView.backgroundColor = kAppMainColor;
  105. self.auctionImgView.image = [UIImage imageNamed:@"ac_success"];
  106. NSString *string = ASLocalizedString(@"竞拍成功");
  107. NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:string];
  108. [attr setAttributes:@{NSFontAttributeName : [UIFont systemFontOfSize:20.0]} range:NSMakeRange(0, string.length)];
  109. CGFloat width =[string sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:20]}].width;
  110. self.auctionLabel.frame = CGRectMake(self.auctionImgView.frame.size.width+self.auctionImgView.frame.origin.x+5,16,width, 20);
  111. self.auctionLabel.attributedText = attr;
  112. self.auctionButton.frame = CGRectMake(self.auctionLabel.frame.size.width+self.auctionLabel.frame.origin.x+5,16,65 ,20);
  113. self.auctionButton.backgroundColor = kYellowColor;
  114. [self.auctionButton setTitleColor:kAppMainColor forState:0];
  115. [self.auctionButton setTitle:ASLocalizedString(@"竞拍结束")forState:0];
  116. }
  117. self.auctionButton.layer.cornerRadius = self.auctionButton.frame.size.height/2;
  118. }
  119. }
  120. @end