[英]In iOS 7 is there a way to display an image over the tab bar?
我是否想在标签栏上显示静态图像? 该图像不会覆盖整个选项卡栏,而只是一部分。 但我仍然希望能够使用这些标签。
我正在寻找做这样的事情。 我可以在选项卡栏中获取图像,但是我希望像在中间的图像一样在选项卡栏上显示图像:
用图像分配一个UIImageView并将其添加到Appdelegate的窗口中,直接在选项卡栏上方。 在将ImageView添加到窗口之前,请确保禁用它。
它会在选项卡栏上方,而无需执行任何操作。
更新:
从appDelegate获取窗口,
Appdelegate *appDelegate = ((Appdelegate*)[UIApplication sharedApplication]).delegate;
UIWindow *appDelegateWindow = appDelegate.window;
然后分配图像视图。
UIImageView *imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"image.png"]];
[imageView sizeToFit];
设置图像视图的框架并将其添加到窗口。
[imageView setFrame:CGRectMake(0,380,50,50)];
[appDelegateWindow addSubView:imageView];
您可以在AppDelegate.m中执行以下操作:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//Allocate an imageView
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"imageTabBar.png"]];
//UITabBarController should be your rootViewController
UITabBarController *tabBarController = (UITabBarController *) self.window.rootViewController;
//set the imageView
[tabBarController.tabBar addSubview:imageView];
// Send ImageView back
[tabBarController.tabBar sendSubviewToBack:imageView];
}
这是模拟器中的结果 :
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.