UINavigationBar custom title position

前端 未结 2 1446
无人共我
无人共我 2020-12-15 05:02

I have a custom made UINavigationBar (different size, background etc) that has inside a custom title view. I used this code to achieve this:

UIView * mainVie         


        
相关标签:
2条回答
  • 2020-12-15 05:14

    You created you UINavigationBar with a height of 80 points, when a standard UINavigationBar has 44 pts. It probably position it centred it on a 44 pts based centre...

    You can try to make a UIView with a height of 80 pts and add the UILabel centred inside it. (not tested, just a guess)

    0 讨论(0)
  • 2020-12-15 05:21

    You can use setTitleVerticalPositionAdjustment:forBarMetrics: in iOS 5 to change the title position, it works on normal title e.g.:

    CGFloat verticalOffset = -4;
    [[UINavigationBar appearance] setTitleVerticalPositionAdjustment:verticalOffset forBarMetrics:UIBarMetricsDefault];
    
    0 讨论(0)
提交回复
热议问题