UIView+AnimationProperty.m 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. //
  2. // UIView+AnimationProperty.m
  3. // AlertViewDemo
  4. //
  5. // Created by YouXianMing on 15/10/15.
  6. // Copyright © 2015年 ZiPeiYi. All rights reserved.
  7. //
  8. #import "UIView+AnimationProperty.h"
  9. #import <objc/runtime.h>
  10. @implementation UIView (AnimationProperty)
  11. #pragma mark - Scale.
  12. NSString * const _recognizerScale = @"_recognizerScale";
  13. - (void)setScale:(CGFloat)scale {
  14. objc_setAssociatedObject(self, (__bridge const void *)(_recognizerScale), @(scale), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
  15. self.transform = CGAffineTransformMakeScale(scale, scale);
  16. }
  17. - (CGFloat)scale {
  18. NSNumber *scaleValue = objc_getAssociatedObject(self, (__bridge const void *)(_recognizerScale));
  19. return scaleValue.floatValue;
  20. }
  21. #pragma mark - Angle.
  22. NSString * const _recognizerAngle = @"_recognizerAngle";
  23. - (void)setAngle:(CGFloat)angle {
  24. objc_setAssociatedObject(self, (__bridge const void *)(_recognizerAngle), @(angle), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
  25. self.transform = CGAffineTransformMakeRotation(angle);
  26. }
  27. - (CGFloat)angle {
  28. NSNumber *angleValue = objc_getAssociatedObject(self, (__bridge const void *)(_recognizerAngle));
  29. return angleValue.floatValue;
  30. }
  31. @end