Aucune description

LGAlertViewButtonProperties.m 6.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. //
  2. // LGAlertViewButtonProperties.m
  3. // LGAlertView
  4. //
  5. //
  6. // The MIT License (MIT)
  7. //
  8. // Copyright © 2015 Grigory Lutkov <Friend.LGA@gmail.com>
  9. // (https://github.com/Friend-LGA/LGAlertView)
  10. //
  11. // Permission is hereby granted, free of charge, to any person obtaining a copy
  12. // of this software and associated documentation files (the "Software"), to deal
  13. // in the Software without restriction, including without limitation the rights
  14. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  15. // copies of the Software, and to permit persons to whom the Software is
  16. // furnished to do so, subject to the following conditions:
  17. //
  18. // The above copyright notice and this permission notice shall be included in all
  19. // copies or substantial portions of the Software.
  20. //
  21. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  22. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  23. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  24. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  25. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  26. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  27. // SOFTWARE.
  28. //
  29. #import "LGAlertViewButtonProperties.h"
  30. @interface LGAlertViewButtonProperties ()
  31. @property (readwrite) BOOL userTitleColor;
  32. @property (readwrite) BOOL userTitleColorHighlighted;
  33. @property (readwrite) BOOL userTitleColorDisabled;
  34. @property (readwrite) BOOL userBackgroundColor;
  35. @property (readwrite) BOOL userBackgroundColorHighlighted;
  36. @property (readwrite) BOOL userBackgroundColorDisabled;
  37. @property (readwrite) BOOL userIconImage;
  38. @property (readwrite) BOOL userIconImageHighlighted;
  39. @property (readwrite) BOOL userIconImageDisabled;
  40. @property (readwrite) BOOL userTextAlignment;
  41. @property (readwrite) BOOL userFont;
  42. @property (readwrite) BOOL userNumberOfLines;
  43. @property (readwrite) BOOL userLineBreakMode;
  44. @property (readwrite) BOOL userMinimumScaleFactor;
  45. @property (readwrite) BOOL userAdjustsFontSizeTofitWidth;
  46. @property (readwrite) BOOL userIconPosition;
  47. @property (readwrite) BOOL userEnabled;
  48. @end
  49. @implementation LGAlertViewButtonProperties
  50. - (id)initWithCoder:(NSCoder *)coder {
  51. self = [super init];
  52. if (self) {
  53. self.titleColor = [coder decodeObjectForKey:@"titleColor"];
  54. self.titleColorHighlighted = [coder decodeObjectForKey:@"titleColorHighlighted"];
  55. self.titleColorDisabled = [coder decodeObjectForKey:@"titleColorDisabled"];
  56. self.backgroundColor = [coder decodeObjectForKey:@"backgroundColor"];
  57. self.backgroundColorHighlighted = [coder decodeObjectForKey:@"backgroundColorHighlighted"];
  58. self.backgroundColorDisabled = [coder decodeObjectForKey:@"backgroundColorDisabled"];
  59. self.iconImage = [coder decodeObjectForKey:@"iconImage"];
  60. self.iconImageHighlighted = [coder decodeObjectForKey:@"iconImageHighlighted"];
  61. self.iconImageDisabled = [coder decodeObjectForKey:@"iconImageDisabled"];
  62. self.font = [coder decodeObjectForKey:@"font"];
  63. }
  64. return self;
  65. }
  66. - (void)encodeWithCoder:(NSCoder *)coder {
  67. [coder encodeObject:self.titleColor forKey:@"titleColor"];
  68. [coder encodeObject:self.titleColorHighlighted forKey:@"titleColorHighlighted"];
  69. [coder encodeObject:self.titleColorDisabled forKey:@"titleColorDisabled"];
  70. [coder encodeObject:self.backgroundColor forKey:@"backgroundColor"];
  71. [coder encodeObject:self.backgroundColorHighlighted forKey:@"backgroundColorHighlighted"];
  72. [coder encodeObject:self.backgroundColorDisabled forKey:@"backgroundColorDisabled"];
  73. [coder encodeObject:self.iconImage forKey:@"iconImage"];
  74. [coder encodeObject:self.iconImageHighlighted forKey:@"iconImageHighlighted"];
  75. [coder encodeObject:self.iconImageDisabled forKey:@"iconImageDisabled"];
  76. [coder encodeObject:self.font forKey:@"font"];
  77. }
  78. #pragma mark -
  79. - (void)setTitleColor:(UIColor *)titleColor {
  80. _titleColor = titleColor;
  81. self.userTitleColor = YES;
  82. }
  83. - (void)setTitleColorHighlighted:(UIColor *)titleColorHighlighted {
  84. _titleColorHighlighted = titleColorHighlighted;
  85. self.userTitleColorHighlighted = YES;
  86. }
  87. - (void)setTitleColorDisabled:(UIColor *)titleColorDisabled {
  88. _titleColorDisabled = titleColorDisabled;
  89. self.userTitleColorDisabled = YES;
  90. }
  91. - (void)setBackgroundColor:(UIColor *)backgroundColor {
  92. _backgroundColor = backgroundColor;
  93. self.userBackgroundColor = YES;
  94. }
  95. - (void)setBackgroundColorHighlighted:(UIColor *)backgroundColorHighlighted {
  96. _backgroundColorHighlighted = backgroundColorHighlighted;
  97. self.userBackgroundColorHighlighted = YES;
  98. }
  99. - (void)setBackgroundColorDisabled:(UIColor *)backgroundColorDisabled {
  100. _backgroundColorDisabled = backgroundColorDisabled;
  101. self.userBackgroundColorDisabled = YES;
  102. }
  103. - (void)setIconImage:(UIImage *)iconImage {
  104. _iconImage = iconImage;
  105. self.userIconImage = YES;
  106. }
  107. - (void)setIconImageHighlighted:(UIImage *)iconImageHighlighted {
  108. _iconImageHighlighted = iconImageHighlighted;
  109. self.userIconImageHighlighted = YES;
  110. }
  111. - (void)seticonImageDisabled:(UIImage *)iconImageDisabled {
  112. _iconImageDisabled = iconImageDisabled;
  113. self.userIconImageDisabled = YES;
  114. }
  115. - (void)setTextAlignment:(NSTextAlignment)textAlignment {
  116. _textAlignment = textAlignment;
  117. self.userTextAlignment = YES;
  118. }
  119. - (void)setFont:(UIFont *)font {
  120. _font = font;
  121. self.userFont = YES;
  122. }
  123. - (void)setNumberOfLines:(NSUInteger)numberOfLines {
  124. _numberOfLines = numberOfLines;
  125. self.userNumberOfLines = YES;
  126. }
  127. - (void)setLineBreakMode:(NSLineBreakMode)lineBreakMode {
  128. _lineBreakMode = lineBreakMode;
  129. self.userLineBreakMode = YES;
  130. }
  131. - (void)setMinimumScaleFactor:(CGFloat)minimumScaleFactor {
  132. _minimumScaleFactor = minimumScaleFactor;
  133. self.userMinimumScaleFactor = YES;
  134. }
  135. - (void)setAdjustsFontSizeToFitWidth:(BOOL)adjustsFontSizeToFitWidth {
  136. _adjustsFontSizeToFitWidth = adjustsFontSizeToFitWidth;
  137. self.userAdjustsFontSizeTofitWidth = YES;
  138. }
  139. - (void)setIconPosition:(LGAlertViewButtonIconPosition)iconPosition {
  140. _iconPosition = iconPosition;
  141. self.userIconPosition = YES;
  142. }
  143. - (void)setEnabled:(BOOL)enabled {
  144. _enabled = enabled;
  145. self.userEnabled = YES;
  146. }
  147. @end