是否可以在导航栏中更改标题视图的大小?我想要使用的一些标题太长而无法以当前大小显示,所以我想横向扩展标题视图.这是我到目前为止所尝试的:
UIView *testView = [[UIView alloc] initWithFrame:CGRectMake(0,500,32)]; [testView setBackgroundColor:[UIColor redColor]]; self.navigationItem.titleView = testView;
无论我的宽度有多大,它都不会超出某一点.这就是我所看到的:
反正有没有绕过这个?谢谢您的帮助
解决方法
AFAIK现在有了简单的方法.但是你可以使用UINavigationController的方法
- (instancetype)initWithNavigationBarClass:(Class)navigationBarClass toolbarClass:(Class)toolbarClass;
使用自定义UINavigationBar创建UINavigationController.
Use this initializer to make the navigation controller use your custom bar class. Passing nil for navigationBarClass will get you UINavigationBar,nil for toolbarClass gets UIToolbar. The arguments must otherwise be subclasses of the respective UIKit classes.