- UITabBar* tabBar = [[UITabBar alloc] initWithFrame:CGRectMake(40,0.0,240,70)];
- [tabBar setBackgroundImage:[UIImage imageNamed:@"titlebarbg.png"]];
- UITabBarItem * tabBarItem1 = [[UITabBarItem alloc] initWithTitle:@"人数" image:nil tag:0];
- UITabBarItem * tabBarItem2 = [[UITabBarItem alloc] initWithTitle:@"人均" image:nil tag:1];
- UITabBarItem * tabBarItem3 = [[UITabBarItem alloc] initWithTitle:@"距离" image:nil tag:2];
- UITabBarItem * tabBarItem4 = [[UITabBarItem alloc] initWithTitle:@"好评" image:nil tag:3];
- NSArray *tabBarItemArray = [[NSArray alloc] initWithObjects: tabBarItem1, tabBarItem2, tabBarItem3, tabBarItem4,nil];
- [tabBar setItems: tabBarItemArray];
- tabBar.delegate =self;
- - (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item
- {
- NSLog(@"itemClick: %d",item.tag);
- }
@interface ViewController : UIViewController<UITabBarDelegate>