How can I get a transparent background in my iOS app so I can see the Home Screen wallpaper?

浪尽此生 提交于 2019-12-28 02:53:31

问题


I’m fairly sure this is going to be straight forward in that it’s probably not possible.

Basically, I’d like to be able to lightly see the background wallpaper through my view in the same way that the new Newsstand app does.

I've tried changing the alpha value of the view, and the background color to clear, but neither of these seem to do it.


回答1:


Apple has removed the ability to use this api in 7.0.3. What a shame.

You certainly can in iOS7, at least as of a few days ago. In our app once you set the following it makes your background transparent and shows the user wallpaper. If you try to programmatically take a screenshot, it will just show black instead.

  1. Set UIApplicationIsOpaque to false in the project plist

  2. In the app delegate load function:

    self.window.backgroundColor = [UIColor clearColor];

    self.window.opaque = NO;

  3. Set the UIViewController.view's background color to [UIColor clearColor]




回答2:


Good news. From iOS 13, the background transparency can finally be enabled for all third-party apps. It’s no longer a private API.

In your app’s Info.plist file, set the boolean value for UIApplicationIsOpaque to NO.

And now the user’s wallpaper is visible inside your app.




回答3:


It's not possible in iOS. While your app is running it does not mean that there is home screen behind your app.

However, If you do want to do it, there is a way that you make your app go in background, take screenshot and use that image as your background which will feel like home screen.

See this post. In this link, the accepted answer gives a way to take screenshot of home screen while your app is in background. But that's been achieved through a private API, which means your app probably will get rejected by App Store on time of submission.



来源:https://stackoverflow.com/questions/18913155/how-can-i-get-a-transparent-background-in-my-ios-app-so-i-can-see-the-home-scree

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!