您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. @interface NCNotificationDateLabel
  2. @property (assign,nonatomic) NSString *text;
  3. -(void)sizeToFit;
  4. @end
  5. @interface NCLookHeaderContentView
  6. -(void)_updateDateLabelFontForShortLook;
  7. @end
  8. static bool is24h;
  9. %hook NCLookHeaderContentView
  10. -(void)_updateDateLabelFontForShortLook{
  11. %orig;
  12. NSDate *date = MSHookIvar<NSDate *>(self, "_date");
  13. NSInteger format = MSHookIvar<NSInteger >(self, "_dateFormatStyle");
  14. if((date != nil) && (format == 1)){
  15. NCNotificationDateLabel *dateLabel = MSHookIvar<NCNotificationDateLabel *>(self, "_dateLabel");
  16. NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
  17. if(is24h)
  18. {
  19. [dateFormatter setDateFormat:@"HH:mm"];
  20. }else{
  21. [dateFormatter setDateFormat:@"h:mm a"];
  22. }
  23. dateLabel.text = [dateFormatter stringFromDate:date];
  24. [dateLabel sizeToFit];
  25. [dateFormatter release];
  26. }
  27. }
  28. -(void)dateLabelDidChange:(id)arg1{
  29. %orig(arg1);
  30. [self _updateDateLabelFontForShortLook];
  31. }
  32. %end
  33. %ctor{
  34. NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
  35. [formatter setLocale:[NSLocale currentLocale]];
  36. [formatter setDateStyle:NSDateFormatterNoStyle];
  37. [formatter setTimeStyle:NSDateFormatterShortStyle];
  38. NSString *dateString = [formatter stringFromDate:[NSDate date]];
  39. NSRange amRange = [dateString rangeOfString:[formatter AMSymbol]];
  40. NSRange pmRange = [dateString rangeOfString:[formatter PMSymbol]];
  41. is24h = (amRange.location == NSNotFound && pmRange.location == NSNotFound);
  42. [formatter release];
  43. }