YXDeviceCollectionViewCell.m 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //
  2. // YXDeviceCollectionViewCell.m
  3. // Temperature
  4. //
  5. // Created by z on 2025/1/17.
  6. //
  7. #import "YXDeviceCollectionViewCell.h"
  8. @implementation YXDeviceCollectionViewCell
  9. - (instancetype)initWithFrame:(CGRect)frame
  10. {
  11. if (self = [super initWithFrame:frame])
  12. {
  13. self.picImgView = [[UIImageView alloc] init];
  14. self.picImgView.contentMode = UIViewContentModeScaleAspectFit;
  15. [self.contentView addSubview:self.picImgView];
  16. [self.picImgView mas_makeConstraints:^(MASConstraintMaker *make) {
  17. make.centerX.equalTo(self.mas_centerX);
  18. make.top.equalTo(@20);
  19. make.width.equalTo(self.contentView.mas_width).multipliedBy(0.5);
  20. make.height.equalTo(self.picImgView.mas_width);
  21. }];
  22. self.textLabel = [[UILabel alloc] init];
  23. self.textLabel.font = [UIFont systemFontOfSize:13];
  24. self.textLabel.textAlignment = NSTextAlignmentCenter;
  25. self.textLabel.numberOfLines = 2;
  26. [self.contentView addSubview:self.textLabel];
  27. [self.textLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  28. make.top.equalTo(self.picImgView.mas_bottom);
  29. make.left.equalTo(@10);
  30. make.right.equalTo(@-10);
  31. make.bottom.equalTo(@0);
  32. }];
  33. }
  34. return self;
  35. }
  36. @end