开发者

iOS: how to make nav title align left when back button is hidden

I've followed this code to implement a title and subtitle in the navigation bar: iPhone Title and Subtitle in Navigation Bar which works really well. However, I have a section where I've hidden the back button by doing:

self.navigationItem.hidesBackButton = YES;

and I'd like the title to take up the extra room开发者_高级运维 on the left where the button used to be.

Is this possible?


Set the origin of navigationItem.titleView

For example

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    if (self.navigationItem.hidesBackButton) {
        CGRect frame = self.navigationItem.titleView.frame;
        frame.origin.x = 10;
        self.navigationItem.titleView.frame = frame;
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜