Setting iOS background/lockscreen image programmatically?

别等时光非礼了梦想. 提交于 2020-01-01 02:47:08

问题


I'd like to be able to set the lockscreen background image programmatically. I'm aware that this is only possible for jailbroken iOS devices.

Here are some things that I've tried:

  1. Place a LockBackground.png in /private/var/mobile/Library/SpringBoard/. This works but requires a hard respring. notify_post("com.apple.language.changed"); doesn't work for a soft respring.

  2. Use class-dump to dump private methods of UIKit. UIKit in 4.2 used to have a method called + (void)setDesktopImageData:(id)fp8; but it appears to be missing in 4.3 and above.

Is there anything that I'm missing?


回答1:


I found this in the SpringBoard dump which I think will be of use to you:

In SBWallpaperView.h:

- (void)replaceWallpaperWithImage:(id)image;

And in SBUIController.h:

- (id)wallpaperView;

So you can do something like:

[(SBWallpaperView *)[SBUIController sharedInstance] wallpaperView] replaceWallpaperWithImage:anImage];

That's one way.

The other one I found was to use SBWallpaperView's + (void)noteWallpaperPreferencesChanged;, I'm not that sure about this one, but it seems like if you do what you did in the first thing you tried, and then use this instead of a respring, it might work.



来源:https://stackoverflow.com/questions/6752202/setting-ios-background-lockscreen-image-programmatically

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