Objective c 如何在选项卡栏上添加客户端徽标
在我的iPad应用程序中,如何在右下角添加客户徽标的图像? 我的应用程序包含5个选项卡。 我为iOS 4.3工作Objective c 如何在选项卡栏上添加客户端徽标,objective-c,ios,ipad,tabbar,Objective C,Ios,Ipad,Tabbar,在我的iPad应用程序中,如何在右下角添加客户徽标的图像? 我的应用程序包含5个选项卡。 我为iOS 4.3工作 UIImage *navBarImage = [UIImage imageNamed:@"images/menubar.png"]; [[UINavigationBar appearance] setBackgroundImage:navBarImage forBarMetrics:UIBarMetricsDefault]
UIImage *navBarImage = [UIImage imageNamed:@"images/menubar.png"];
[[UINavigationBar appearance] setBackgroundImage:navBarImage
forBarMetrics:UIBarMetricsDefault];
UIImage *barButton = [UIImage imageNamed:@"images/barbutton.png"];
[[UIBarButtonItem appearance] setBackgroundImage:barButton
forState:UIControlStateNormal
barMetrics:UIBarMetricsDefault];
UIImage *backButton = [UIImage imageNamed:@"images/back.png"];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:backButton
forState:UIControlStateNormal
barMetrics:UIBarMetricsDefault];
UIImage *tabBarBackground = [UIImage imageNamed:@"images/tabbar.png"];
[[UITabBar appearance] setBackgroundImage:tabBarBackground];
[[UITabBar appearance] setSelectionIndicatorImage:[UIImage imageNamed:@"images/selection-tab.png"]];
你可以在这里找到更多
或者google for UIAppearance您需要设置选项卡栏的宽度,以便为UIImageView留出空间 将UIImageView添加为子视图UITabBarcontroller.view并定位它 使用以下代码设置UITabBarController的宽度
for(UIView *view in tabBarController.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
view.frame = //set your rect
}
}
一种方法是控制UITabBar。使此控件在每个选项卡上都有一个UIButton,然后将这些按钮连接到一个方法,该方法通过使用setSelected和已按下选项卡的索引以编程方式调用选项卡栏press
我认为你可以用iOS5或更高版本做更好的(更少的黑客)定制 我建议添加一个常规的
uitabaritem
并禁用它:
[[tabBar items][4] setEnabled:NO];
“4”是选项卡栏中的第五项也是最后一项。如果您不确定将来是否要添加其他内容,可以使用tabBar.items.count-1来替换它
静态项将具有某种水印效果,因为它已被禁用。您的问题需要更详细一点:是否希望此徽标成为选项卡栏控制器的一部分,并像所有其他选项卡一样在触摸时实际执行某些操作?不,我只想像静态图像一样添加它。:)希望这个链接能让你开心!!![点击这里][1][1]:@ArunKumarTiwari评论中的链接:[Link](http://example.com)
==>请告诉我更多细节,因为我试图在tabitem中添加图像作为子视图,但当我启动应用程序时,它会产生一个问题,这取决于启动方向(Lan/Por)以及将视图旋转到横向或纵向后的情况?我已经使用了shouldautorotate方法,这样当方向改变时,它会自动移动。嗯,这个水印效果不是解决我问题的合适方法,仍然感谢您的建议。如果您能提供任何其他建议,我将不胜感激。:)您是否使用了UITabBarController
?是的,我使用了self.window.rootViewController=self.tabBarController;应用程序内代理。