我想在xcode 4.2中以编程方式在标签栏上添加图像。我尝试了很多次,但仍然无法完成我的任务。正如我已经问过的问题,但没有人给我满意的答案在Here 。提前致谢。度过快乐的一天。在xcode 4.2中以编程方式添加图像
1
A
回答
1
试试下面的代码
UITabBarItem *tabItem = [[[UITabBarItem tabBar] items] objectAtIndex:yourIndex];
[tabItem setTitle:@"theTitle"];
[tabItem setImage:[UIImage imageNamed:@"yourImage.png"]];
0
写这个方法在你的ViewController:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.tabBarItem.image = [UIImage imageNamed:@"image.png"];
}
return self;
}
1
iOS 5的外观API,
UIImage* tabBarBackground = [UIImage imageNamed:@"tabbar.png"];
[[UITabBar appearance] setBackgroundImage:tabBarBackground];
也看到这个thread,第二高的投票答案解释这两种情况下< 5.0 => 5.0的情况下。
相关问题
- 1. UITableViewAutomaticDimension以编程方式添加图像
- 2. 以编程方式在Android中添加图像WaterMark
- 3. 以编程方式在HTML5中添加图像
- 4. 以编程方式加载图像
- 5. 以编程方式添加视图
- 6. XCODE Obj-C以编程方式添加UiimageView在
- 7. 以编程方式在Excel 2007中以编程方式添加条件格式
- 8. 无法在Xcode 4.2中设置标签栏图像编程
- 9. 以任何方式在.NET中以编程方式添加HttpHandler?
- 10. 印刷时以编程方式添加脚注(图像)
- 11. Datagrid图像列以编程方式添加wpf
- 12. 如何以编程方式添加barbutton与图像
- 13. 以编程方式向Magento Products添加多个图像
- 14. 图像添加到AnimationDrawable以编程方式泄漏内存
- 15. android添加图像以编程方式绘制
- 16. 以编程方式向图像添加命名空间效果
- 17. 以编程方式将图像添加到UINavigationBar
- 18. 以编程方式将模糊图像背景添加到xib
- 19. 如何以编程方式将图像添加到Drupal节点?
- 20. 以编程方式将图像添加到Crystall报告
- 21. WPF:以编程方式向图像添加边框
- 22. 如何以编程方式将图像添加到Android PopupMenu()?
- 23. 以编程方式将图像添加到Drupal节点
- 24. 如何以编程方式创建UITableView并在Xcode 4.2中填充NSArray?
- 25. 如何以编程方式将多个图像添加到可编辑视图
- 26. 以编程方式在布局中添加子视图
- 27. 如何以编程方式在UITableView中添加视图?
- 28. 在以编程方式添加的子视图中绘制?
- 29. Android以编程方式在for循环中添加视图
- 30. 以编程方式在swift中添加全尺寸视图