Guest User

Untitled

a guest
Apr 28th, 2012
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. How to make Autoresize property work in Xcode 4.3?
  2. myLabel.adjustsFontSizeToFitWidth = YES;
  3.  
  4. // UIView+viewRecursion.h
  5. @interface UIView (viewRecursion)
  6. - (NSMutableArray*) allSubViews;
  7. @end
  8. // UIView+viewRecursion.m
  9. @implementation UIView (viewRecursion)
  10. - (NSMutableArray*)allSubViews
  11. {
  12. NSMutableArray *arr=[[NSMutableArray alloc] init];
  13. [arr addObject:self];
  14. for (UIView *subview in self.subviews)
  15. {
  16. [arr addObjectsFromArray:(NSArray*)[subview allSubViews]];
  17. }
  18. return arr;
  19. }
  20. @end
  21.  
  22. +(void)fixLabels:(UIView *)theView{
  23.  
  24. for(UIView *v in [theView allSubViews])
  25. {
  26. if([v isKindOfClass:[UILabel class]])
  27. {
  28. if( !((UILabel*)v).adjustsFontSizeToFitWidth ){
  29. ((UILabel*)v).adjustsFontSizeToFitWidth=YES;
  30. // NSLog(@"fixed %@", theView);
  31. }
  32. }
  33. }
  34. }
  35.  
  36. [Utility fixLabels:self.view];
  37.  
  38. myLabel.adjustsFontSizeToFitWidth = YES;
Advertisement
Add Comment
Please, Sign In to add comment