ios – 在导航栏中更改titleview的大小

是否可以在导航栏中更改标题视图的大小?我想要使​​用的一些标题太长而无法以当前大小显示,所以我想横向扩展标题视图.这是我到目前为止所尝试的:

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.

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...