4
votes

For a custom layout in iOS6, i have created a subclass of UINavigationBar and overridden the drawRect method. I specify the class in interface builder, because not every controller needs to have this effect. This is also the reason why i cannot use a category.

But now with iOS7, i want to use the default navigationbar and not the overriden behaviour. The code below does not work:

-(void)drawRect:(CGRect)rect
{
    if([self isOS7]) {
       [super drawRect:rect];
    } 
    else {
        // custom drawing
    }
}

The problem is, by actually defining the drawRect, ios7 fails to correctly draw the navigation bar under the status bar. If i leave out the entire drawrect, it works (but then it doesn't work under older devices!

Any suggestions?

1
drawRect, isn't called... right? I have the same problemSam
Did you find a solution/workaround? I can imagine the caller is checking a respondsToSelector: somewhere...Rob van der Veer
Seams to be a bug! When you remove the whole method and start with ios7, it works. super drawRect:rect doesn't work... so it seams that it's not possible to override this method in io7 correctely. Do you agree?Sam
@Sam, that was the whole point of my post...Rob van der Veer
Sorry i missed the last sentence :-).Sam

1 Answers

1
votes

You can solve it, if you add a new UIView as a Subview and do the stuff there instead in draw rect.

UITableViewCell drawInRect iOS7