CommoditysCell.m 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. //
  2. // CommoditysCell.m
  3. // jitao
  4. //
  5. // Created by 罗云飞 on 2018/1/11.
  6. // Copyright © 2018年 罗云飞. All rights reserved.
  7. //
  8. #import "CommoditysCell.h"
  9. @implementation CommoditysCell
  10. - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  11. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  12. if (self) {
  13. UILabel *line = [UILabel new];
  14. line.backgroundColor = NewLineGrayColor;
  15. [self.contentView addSubview:line];
  16. line.sd_layout
  17. .leftEqualToView(self.contentView)
  18. .heightIs(10)
  19. .rightEqualToView(self.contentView)
  20. .topEqualToView(self.contentView);
  21. }
  22. return self;
  23. }
  24. - (void)assignment:(OrderdetailModel*)model {
  25. for (int i = 0; i<model.commoditys.count; i++) {
  26. UILabel *commoditys = [UILabel new];
  27. commoditys.text = [NSString stringWithFormat:@"%@",model.commoditys[i][@"commodityName"]];
  28. commoditys.font = NewFont(fitScreenWidth(14));
  29. commoditys.textAlignment = NSTextAlignmentLeft;
  30. commoditys.frame = CGRectMake(15, 20+(30*i), SCREEN_WIDTH/2-30-20, 15);
  31. commoditys.backgroundColor = NewClearColor;
  32. commoditys.lineBreakMode = NSLineBreakByTruncatingTail;
  33. [self.contentView addSubview:commoditys];
  34. UILabel *shuliang = [UILabel new];
  35. shuliang.text = [NSString stringWithFormat:@"x%@",model.commoditys[i][@"commodityQuantity"]];
  36. shuliang.font = NewFont(fitScreenWidth(12));
  37. shuliang.textAlignment = NSTextAlignmentCenter;
  38. shuliang.backgroundColor = NewClearColor;
  39. shuliang.frame = CGRectMake(SCREEN_WIDTH/2-15, 20+(30*i), 30, 15);
  40. [self.contentView addSubview:shuliang];
  41. UILabel *jiage = [UILabel new];
  42. jiage.font = NewFont(fitScreenWidth(14));
  43. jiage.text = [NSString stringWithFormat:@"价格:%@",model.commoditys[i][@"commodityPrice"]];
  44. jiage.textAlignment = NSTextAlignmentRight;
  45. jiage.backgroundColor = NewClearColor;
  46. [jiage setSingleLineAutoResizeWithMaxWidth:0];
  47. [self.contentView addSubview:jiage];
  48. jiage.sd_layout
  49. .rightSpaceToView(self.contentView, 15)
  50. .heightIs(15)
  51. .yIs(20+(30*i));
  52. }
  53. }
  54. - (void)awakeFromNib {
  55. [super awakeFromNib];
  56. // Initialization code
  57. }
  58. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  59. [super setSelected:selected animated:animated];
  60. // Configure the view for the selected state
  61. }
  62. @end