I do this quite a bit in my code:
self.sliderOne.frame = CGRectMake(newX, 0, self.sliderOne.frame.size.width, self.sliderOne.frame.size.height);
Is there any way to avoid this tedious code? I have tried this type of thing:
self.sliderOne.frame.origin.x = newX;
but I get a Lvalue required as left operand of assignment error.
I finally followed @Dave DeLong’s suggestion and made a category. All you have to do is import it in any class that wants to take advantage of it.
UIView+AlterFrame.h
UIView+AlterFrame.m
I could DRY up the methods using blocks… I’ll do that at some point soon, I hope.
Later: I just noticed
CGRectOffsetandCGRectInset, so this category could be cleaned up a bit (if not eliminated altogether).