JDStatusBarStyle.m 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. //
  2. // JDStatusBarStyle.m
  3. // JDStatusBarNotificationExample
  4. //
  5. // Created by Markus on 04.12.13.
  6. // Copyright (c) 2013 Markus. All rights reserved.
  7. //
  8. #import "JDStatusBarStyle.h"
  9. NSString *const JDStatusBarStyleError = @"JDStatusBarStyleError";
  10. NSString *const JDStatusBarStyleWarning = @"JDStatusBarStyleWarning";
  11. NSString *const JDStatusBarStyleSuccess = @"JDStatusBarStyleSuccess";
  12. NSString *const JDStatusBarStyleMatrix = @"JDStatusBarStyleMatrix";
  13. NSString *const JDStatusBarStyleDefault = @"JDStatusBarStyleDefault";
  14. NSString *const JDStatusBarStyleDark = @"JDStatusBarStyleDark";
  15. @implementation JDStatusBarStyle
  16. - (instancetype)copyWithZone:(NSZone*)zone;
  17. {
  18. JDStatusBarStyle *style = [[[self class] allocWithZone:zone] init];
  19. style.barColor = self.barColor;
  20. style.textColor = self.textColor;
  21. style.textShadow = self.textShadow;
  22. style.font = self.font;
  23. style.textVerticalPositionAdjustment = self.textVerticalPositionAdjustment;
  24. style.animationType = self.animationType;
  25. style.progressBarColor = self.progressBarColor;
  26. style.progressBarHeight = self.progressBarHeight;
  27. style.progressBarPosition = self.progressBarPosition;
  28. return style;
  29. }
  30. + (NSArray*)allDefaultStyleIdentifier;
  31. {
  32. return @[JDStatusBarStyleError, JDStatusBarStyleWarning,
  33. JDStatusBarStyleSuccess, JDStatusBarStyleMatrix,
  34. JDStatusBarStyleDark];
  35. }
  36. + (JDStatusBarStyle*)defaultStyleWithName:(NSString*)styleName;
  37. {
  38. // setup default style
  39. JDStatusBarStyle *style = [[JDStatusBarStyle alloc] init];
  40. style.barColor = [UIColor whiteColor];
  41. style.progressBarColor = [UIColor greenColor];
  42. style.progressBarHeight = 1.0;
  43. style.progressBarPosition = JDStatusBarProgressBarPositionBottom;
  44. style.textColor = [UIColor grayColor];
  45. style.font = [UIFont systemFontOfSize:12.0];
  46. style.animationType = JDStatusBarAnimationTypeMove;
  47. // JDStatusBarStyleDefault
  48. if ([styleName isEqualToString:JDStatusBarStyleDefault]) {
  49. return style;
  50. }
  51. // JDStatusBarStyleError
  52. else if ([styleName isEqualToString:JDStatusBarStyleError]) {
  53. style.barColor = [UIColor colorWithRed:0.588 green:0.118 blue:0.000 alpha:1.000];
  54. style.textColor = [UIColor whiteColor];
  55. style.progressBarColor = [UIColor redColor];
  56. style.progressBarHeight = 2.0;
  57. return style;
  58. }
  59. // JDStatusBarStyleWarning
  60. else if ([styleName isEqualToString:JDStatusBarStyleWarning]) {
  61. style.barColor = [UIColor colorWithRed:0.900 green:0.734 blue:0.034 alpha:1.000];
  62. style.textColor = [UIColor darkGrayColor];
  63. style.progressBarColor = style.textColor;
  64. return style;
  65. }
  66. // JDStatusBarStyleSuccess
  67. else if ([styleName isEqualToString:JDStatusBarStyleSuccess]) {
  68. style.barColor = [UIColor colorWithRed:0.588 green:0.797 blue:0.000 alpha:1.000];
  69. style.textColor = [UIColor whiteColor];
  70. style.progressBarColor = [UIColor colorWithRed:0.106 green:0.594 blue:0.319 alpha:1.000];
  71. style.progressBarHeight = 1.0+1.0/[[UIScreen mainScreen] scale];
  72. return style;
  73. }
  74. // JDStatusBarStyleDark
  75. else if ([styleName isEqualToString:JDStatusBarStyleDark]) {
  76. style.barColor = [UIColor colorWithRed:0.050 green:0.078 blue:0.120 alpha:1.000];
  77. style.textColor = [UIColor colorWithWhite:0.95 alpha:1.0];
  78. style.progressBarHeight = 1.0+1.0/[[UIScreen mainScreen] scale];
  79. return style;
  80. }
  81. // JDStatusBarStyleMatrix
  82. else if ([styleName isEqualToString:JDStatusBarStyleMatrix]) {
  83. style.barColor = [UIColor blackColor];
  84. style.textColor = [UIColor greenColor];
  85. style.font = [UIFont fontWithName:@"Courier-Bold" size:14.0];
  86. style.progressBarColor = [UIColor greenColor];
  87. style.progressBarHeight = 2.0;
  88. return style;
  89. }
  90. return nil;
  91. }
  92. @end