2

I want to make sure none of my views are misaligned and hence would want to use CGRectIntegral while setting frame on all the uiviews. But I don't want to make it so that all the devs just set the frame like they would normally (eg. view.frame = aCGRect) and it magically works. I tried to add a category and then override the setFrame: method for UIView but that (Obviously!) creates an infinite loop :

-(void)setFrame:(CGRect)frame{
  self.frame = CGRectIntegral(frame)
}

Is there a better way to do this than adding a utility function?

Trunal Bhanse
  • 1,651
  • 1
  • 17
  • 27

1 Answers1

1

If it's just for development/diagnosis, you could perhaps swizzle the original method (-[UIView setFrame:]) but call the original method in your implementation, passing the adjusted rect.

Community
  • 1
  • 1
justin
  • 104,054
  • 14
  • 179
  • 226