我一直在尝试继承 UINavigationController 类来修改背景图像、导航栏大小、后退按钮、标题字体等内容。
经过几个小时和大量阅读后,我明白我不应该继承 UINavigationController 类......
我想有特定的设计并将该设计转移到使用我的自定义 NavigationController 的所有屏幕......
到目前为止,我还没有找到任何优雅的解决方案,大多数解决方案都基于配置仅在下一个屏幕中显示的内容(下一个 View )。
我怎样才能做到这一点?也许使用类别?
提前致谢。
最佳答案
我正在显示 UINavigationcontroller
的自定义 leftbarbutton 的代码.您可以在每个 View Controller 和按钮(左右)中添加此代码
leftButton = [UIButton buttonWithType:UIButtonTypeCustom];
[leftButton setImage:[UIImage imageNamed:@"Yourcutomeimage.png"] forState:UIControlStateNormal];
leftButton.frame = CGRectMake(0, 0, 30, 30);
[leftButton addTarget:self action:@selector(youraction:) forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:leftButton]autorelease];
//或者
self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:leftButton]autorelease];
希望对你有帮助..
关于iphone - 每个屏幕的 NavigationController 自定义后退按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10516839/