RDSHomeTopView.m 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. //
  2. // RDSHomeTopView.m
  3. // Temperature
  4. //
  5. // Created by RD on 2022/10/25.
  6. //
  7. #import "RDSHomeTopView.h"
  8. #import "NSDate+currentDate.h"
  9. @interface RDSHomeTopView ()
  10. @property (weak, nonatomic) IBOutlet UILabel *titleLab;
  11. @property (weak, nonatomic) IBOutlet UILabel *timeLab;
  12. @property (weak, nonatomic) IBOutlet UILabel *tempLab;// 温度
  13. @property (weak, nonatomic) IBOutlet UILabel *weateherTextLab;
  14. @property (weak, nonatomic) IBOutlet UILabel *cityLab;// 城市
  15. @property (weak, nonatomic) IBOutlet UILabel *rhLab;// 湿度
  16. @property (weak, nonatomic) IBOutlet UIImageView *imgView;
  17. @end
  18. @implementation RDSHomeTopView
  19. - (void)awakeFromNib {
  20. [super awakeFromNib];
  21. // Initialization code
  22. _timeLab.text = [NSDate rds_getDayString];
  23. }
  24. - (void)setTitle:(NSString *)title{
  25. _title = title;
  26. _titleLab.text = title;
  27. }
  28. - (void)setModel:(WeatherModel *)model{
  29. _model = model;
  30. _tempLab.text = [NSString stringWithFormat:@"%d", model.now.temp];
  31. _weateherTextLab.text = model.now.text;
  32. _cityLab.text = model.location.city;
  33. _rhLab.text = [NSString stringWithFormat:@"%d%%", model.now.rh];
  34. _imgView.image = [UIImage imageNamed:[NSString stringWithFormat:@"icon_weather_%@", model.now.icon_code]];
  35. }
  36. - (IBAction)onHeadClickAction:(id)sender {
  37. BLOCK_SAFE_RUN(_onHeadClick)
  38. }
  39. @end