Нет описания

XHViewState.m 944B

1234567891011121314151617181920212223242526272829303132333435363738
  1. //
  2. // XHViewState.m
  3. // XHImageViewer
  4. //
  5. // Created by 曾 宪华 on 14-2-17.
  6. // Copyright (c) 2014年 曾宪华 开发团队(http://iyilunba.com ) 本人QQ:543413507 本人QQ群(142557668). All rights reserved.
  7. //
  8. #import "XHViewState.h"
  9. @implementation XHViewState
  10. + (XHViewState *)viewStateForView:(UIView *)view {
  11. static NSMutableDictionary *dict = nil;
  12. if(dict==nil){ dict = [NSMutableDictionary dictionary]; }
  13. XHViewState *state = dict[@(view.hash)];
  14. if(state==nil){
  15. state = [[self alloc] init];
  16. dict[@(view.hash)] = state;
  17. }
  18. return state;
  19. }
  20. - (void)setStateWithView:(UIView *)view {
  21. CGAffineTransform trans = view.transform;
  22. view.transform = CGAffineTransformIdentity;
  23. self.superview = view.superview;
  24. self.frame = view.frame;
  25. self.transform = trans;
  26. self.userInteratctionEnabled = view.userInteractionEnabled;
  27. view.transform = trans;
  28. }
  29. @end