RDSHomeTopView.m 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 *welcomeMessageLabel;
  12. @property (weak, nonatomic) IBOutlet UILabel *timeLab;
  13. @property (weak, nonatomic) IBOutlet UILabel *tempLab;// 温度
  14. @property (weak, nonatomic) IBOutlet UILabel *weateherTextLab;
  15. @property (weak, nonatomic) IBOutlet UILabel *cityLab;// 城市
  16. @property (weak, nonatomic) IBOutlet UILabel *rhLab;// 湿度
  17. @property (weak, nonatomic) IBOutlet UIImageView *imgView;
  18. @end
  19. @implementation RDSHomeTopView
  20. - (void)awakeFromNib {
  21. [super awakeFromNib];
  22. // Initialization code
  23. _timeLab.text = [NSDate rds_getDayString];
  24. }
  25. - (void)setTitle:(NSString *)title{
  26. _title = title;
  27. _titleLab.text = title;
  28. }
  29. - (void)setModel:(WeatherModel *)model{
  30. _model = model;
  31. _tempLab.text = [NSString stringWithFormat:@"%d", model.now.temp];
  32. _weateherTextLab.text = model.now.text;
  33. _cityLab.text = model.location.city;
  34. _rhLab.text = [NSString stringWithFormat:@"%d%%", model.now.rh];
  35. _imgView.image = [UIImage imageNamed:[NSString stringWithFormat:@"icon_weather_%@", model.now.icon_code]];
  36. }
  37. - (void)setSystemParameter:(RDSSystemParameterModel *)systemParameter {
  38. _systemParameter = systemParameter;
  39. self.welcomeMessageLabel.text = systemParameter.nameValue;
  40. }
  41. - (IBAction)onHeadClickAction:(id)sender {
  42. BLOCK_SAFE_RUN(_onHeadClick)
  43. }
  44. @end