how do you override setFrame for a UILabel

ios, ipad, iphone, objective-c

Solution

You need to call `[super setFrame:frame]`.

That will call UILabel's implementation of `setFrame` and not your own. That is what is causing your infinite loop.

Problem

I wanted to override setframe so that it centers the label as well, however doing something like: ``` - (void)setFrame:(CGRect)frame { [self setFrame:frame}; self.center = CGPointMake(self.superview.center.x, kNavigationBarFrameHeight/2); } ``` gives me an infinite loop. So how do I do this?

Original source