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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With