想为我选择的标签设置自定义背景,到目前为止,子类化是我自定义UITAbBar / UITabBarItem的方式。
问题是:有人知道(或知道我在哪里可以找到)设置背景的属性是什么?
所选标签周围有一个较浅的黑色/灰色圆框。这就是我的目标,即改变。
iOS 4.1附带Game Center,他们已经完全定制了UITabBar。我正在寻找类似的东西。
答案 0 :(得分:1)
为了实现上述目标,您需要创建一个自定义UITabBarController
类。
<强> CustomUITabBarController.h 强>
#import <UIKit/UIKit.h>
@interface CustomUITabBarController: UITabBarController {
IBOutlet UITabBar *tabBar1;
}
@property (nonatomic, retain) UITabBar *tabBar1;
@end
<强> CustomUITabBarController.m 强>
#import “CustomUITabBarController.h”
@implementation CustomUITabBarController
@synthesize tabBar1;
- (void)viewDidLoad {
[super viewDidLoad];
tabBar1.backgroundColor = [UIColor clearColor];
CGRect frame = CGRectMake(0, 0, 480, 49);
UIView *v = [[UIView alloc] initWithFrame:frame];
UIImage *i = [UIImage imageNamed:@"customImage.png"];
UIColor *c = [[UIColor alloc] initWithPatternImage:i];
v.backgroundColor = c;
[c release];
[[self tabBar] insertSubview:v atIndex:0];
[v release];
}
@end
然后,您需要更改 MainWindow.xib 并选择标签栏控制器。在属性检查器中,您需要将类更改为自定义类,然后将tabBar1
出口关联到选项卡栏控制器。