我可以使用类类别来覆盖已使用类别实现的方法吗?像这样:
1)原始方法
-(BOOL) method {
return true;
}
Run Code Online (Sandbox Code Playgroud)
2)覆盖方法
-(BOOL) method {
NSLog(@"error?");
return true;
}
Run Code Online (Sandbox Code Playgroud)
这会起作用,还是非法的?
可能重复:
自定义UINavigationBar背景
我正在应用程序委托中以编程方式创建我的uinavigation控制器.我有一个子类UINavigationBar的类,并希望将其指定为控制器的导航栏.在IB中,我只选择控制器,它的栏并将类从默认类更改为我的自定义类.但是我不知道如何在代码中执行此操作.任何帮助将不胜感激.
我正在使用iOS 5 UINavigationBar的UIAppearance协议来自定义我的所有导航栏.
这是我的自定义功能:
- (void)customizeApperance
{
[[UINavigationBar appearance] setTintColor:[UIColor clearColor]];
[[UINavigationBar appearance] setAlpha:0.7];
UIImageView *titleView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"title.png"]];
[[UINavigationBar appearance] setTitleView:titleView];
}
Run Code Online (Sandbox Code Playgroud)
我有两个问题:
首先是颜色不是clearColor黑色.有什么建议?
标题视图根本没有出现.Ray Wenderlich通过添加:[[rootViewController navigationItem] setTitleView: [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"miniLogo.png"]]]in 来演示如何做到这一点applicationDidFinishLaunching.但问题是标题视图只会添加到根视图控制器中.我正在使用一个UINavigationController当我厌倦了替换rootViewControllerwith navigationController(我在AppDelegate中的导航控制器的名称)时,我根本看不到标题视图.我该如何解决这个问题?为什么不工作customizeApperance()?使用外观的关键不仅仅是创建一次标题视图(就像我在函数上面所做的那样)并且在所有导航栏中都是全局的吗?我怎样才能做到这一点?
iphone objective-c uinavigationbar uinavigationcontroller uiappearance