我在内容中间创建了 UITabBar(项目:信息、位置和描述),现在我想为标签栏设置自定义背景图像,默认选择第一个按钮并在用户选择另一个标签栏项目时获取操作。
这是标签栏的ss:http: //dl.dropbox.com/u/77033905/tabBar%20in%20the%20middle.png
告诉我请回答这个问题:
- 如何为这个标签栏设置自定义背景图像?
- 如何获得选定的项目?
- 如何默认选择第一项?
现在我已经创建了 UITabBar 并包含在这个 ViewController 中,下一步是什么?
这是 ViewController.h:
@interface ViewController : UIViewController<UITabBarDelegate> {
UITabBar *tabBar;
}
@property (strong, nonatomic) IBOutlet UITabBar *tabBar;
...
视图.m:
#import "ViewController.h"
@interface ViewController ()
@end
@implementation OfferViewController
@synthesize tabBar;
- (void)viewDidLoad
{
[super viewDidLoad];
UIImage *selectedImage0 = [UIImage imageNamed:@"HomeDB.png"];
UIImage *unselectedImage0 = [UIImage imageNamed:@"HomeLB.png"];
UIImage *selectedImage1 = [UIImage imageNamed:@"ScheduleDB.png"];
UIImage *unselectedImage1 = [UIImage imageNamed:@"ScheduleLB.png"];
UIImage *selectedImage2 = [UIImage imageNamed:@"BuildingsDB.png"];
UIImage *unselectedImage2 = [UIImage imageNamed:@"BuildingsLB.png"];
//UITabBar *tabBar = self.tabBar;
UITabBarItem *item0 = [tabBar.items objectAtIndex:0];
UITabBarItem *item1 = [tabBar.items objectAtIndex:1];
UITabBarItem *item2 = [tabBar.items objectAtIndex:2];
[item0 setFinishedSelectedImage:selectedImage0 withFinishedUnselectedImage:unselectedImage0];
[item1 setFinishedSelectedImage:selectedImage1 withFinishedUnselectedImage:unselectedImage1];
[item2 setFinishedSelectedImage:selectedImage2 withFinishedUnselectedImage:unselectedImage2];
[super viewDidLoad];
}
...
我现在如何默认选择项目并获取用户在某些标签栏项目上的标签?