动态创建标签栏控制器就不说了,就是从视图库中托一些控件,这里要用到得是Tab Bar Controller,然后创建两个插座变量跟拖的控件进行关联。现在我们主要讲一下怎么对Tab Bar Controller进行设置:
(1)设置条目标题
self.title = @"第一个视图"; [self.tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor blackColor],UITextAttributeTextColor,[UIFont fontWithName:nil size:18],UITextAttributeFont, nil] forState:UIControlStateNormal];
(2)系统自带图片
UITabBarItem *t = [[UITabBarItem alloc]initWithTabBarSystemItem:UITabBarSystemItemMostViewed tag:1]; self.tabBarItem = t;
(3)自定义添加图片
UITabBarItem *t1 = [[UITabBarItem alloc]initWithTitle:@"Forward" image:[UIImage imageNamed:@"forward.png"] tag:1]; self.tabBarItem = t1;
时间: 2024-10-05 20:38:55