PKBorderedButton.m 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //
  2. // PKBorderedButton.m
  3. // Pods
  4. //
  5. // Created by Holden, Ryan on 2/7/16.
  6. //
  7. //
  8. #import "PKBorderedButton.h"
  9. #import "UIImage+PKDownloadButton.h"
  10. @implementation PKBorderedButton
  11. - (void)setCornerRadius:(CGFloat)cornerRadius {
  12. _cornerRadius = cornerRadius;
  13. [self updateBackgroundImage];
  14. }
  15. - (void)setLineWidth:(CGFloat)lineWidth {
  16. _lineWidth = lineWidth;
  17. [self updateBackgroundImage];
  18. }
  19. - (void)configureDefaultAppearance {
  20. [self setCornerRadius:4];
  21. [self setLineWidth:1];
  22. }
  23. - (void)updateBackgroundImage {
  24. [self setBackgroundImage:[UIImage borderedImageWithFill:nil radius:self.cornerRadius lineColor:self.tintColor lineWidth:self.lineWidth]
  25. forState:UIControlStateNormal];
  26. [self setBackgroundImage:[UIImage borderedImageWithFill:self.tintColor radius:self.cornerRadius lineColor:self.tintColor lineWidth:self.lineWidth]
  27. forState:UIControlStateHighlighted];
  28. }
  29. - (void)tintColorDidChange {
  30. [super tintColorDidChange];
  31. [self updateBackgroundImage];
  32. }
  33. - (void)cleanDefaultAppearance {
  34. [self setBackgroundImage:nil forState:UIControlStateNormal];
  35. [self setBackgroundImage:nil forState:UIControlStateHighlighted];
  36. [self setAttributedTitle:nil forState:UIControlStateNormal];
  37. [self setAttributedTitle:nil forState:UIControlStateHighlighted];
  38. }
  39. @end