【发布时间】:2012-08-05 21:45:59
【问题描述】:
似乎有很多不同的方法可以改变 UITabBar 的外观。我发现在iOS 5 中,有backgroundImage 等UITabBar 的新属性。但是,我该如何以及在哪里设置呢?
我想继承 UITabBar 并覆盖 initWithFrame 方法,设置背景图像。
虽然我创建了一个新类@interface UITabBarClass : UITabBar 并在initWithFrame 的实现中添加了以下代码:
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
// Initialization code
// Change background image
UIImage *backgroundImage = [UIImage imageWithContentsOfFile:@"uitabbar-background-normal"];
self.backgroundImage = backgroundImage;
}
return self;
}
背景图像不会改变。我也试过用同样的方法写一个日志,它在运行时没有被记录。
任何人都可以提供帮助或建议吗?
提前致谢! :)
【问题讨论】:
标签: objective-c uitabbar