如何在iPhone中以编程方式设置locking屏幕,墙纸和铃声?

在iPhone中,我们可以设置locking屏幕,墙纸和铃声编程?

如果 ,那么请让我知道如何设置它们?

这一切都可以轻松完成,但会被苹果拒绝。

铃声可以通过改变com.apple.SpringBoard.plist ,特别是ringtone键来改变。

以下代码可用于读取自定义铃声的实际铃声标题(由iTunes同步)。

 NSMutableDictionary *custDict = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/private/var/mobile/Media/iTunes_Control/iTunes/Ringtones.plist"]; NSMutableDictionary *dictionary = [custDict objectForKey:@"Ringtones"]; NSArray *keys = [dictionary allKeys]; id key = [keys objectAtIndex:indexPath.row]; NSMutableDictionary *customRingtone = [dictionary objectForKey:key]; NSString *name = [customRingtone objectForKey:@"Name"]; cell.textLabel.text = name; 

壁纸可以覆盖在:

 NSString *homePath1 = @"/private/var/mobile/Library/SpringBoard/HomeBackground.jpg"; NSString *homePath2 = @"/private/var/mobile/Library/SpringBoard/HomeBackgroundPortrait.jpg"; NSString *lockPath1 = @"/private/var/mobile/Library/SpringBoard/LockBackground.jpg"; NSString *lockPath2 = @"/private/var/mobile/Library/SpringBoard/LockBackgroundPortrait.jpg"; 

这些例子被用在我的一个Cydia应用程序中。 他们没有更多的东西,但这些应该让你朝着正确的方向前进。

使用私人API如果你可以检查PLStaticWallpaperImageViewController

由于iOS的变化, WrightsCS的答案在某个时候停止了工作。 不幸的是,如果你想使用未logging的function,这是你必须忍受的。

如果您仍然需要这样做,那么对于仅适用于非App Store应用程序的情况 ,此代码适用于iOS 9.3。 不过,它可能会在任何未来的iOS版本中停止工作。 (请参阅下面的注释:不再适用于iOS 10)

 #import "SBSUIWallpaperPreviewViewController.h" #import <dlfcn.h> // open the private framework dynamically void *handle = dlopen("/System/Library/PrivateFrameworks/SpringBoardUIServices.framework/SpringBoardUIServices", RTLD_NOW); UIImage *wallpaper = [UIImage imageNamed: @"background.jpg"]; Class sbClass = NSClassFromString(@"SBSUIWallpaperPreviewViewController"); // we create a view controller, but don't display it. // just use it to load image and set wallpaper SBSUIWallpaperPreviewViewController *controller = (SBSUIWallpaperPreviewViewController*)[[sbClass alloc] initWithImage: wallpaper]; [controller setWallpaperForLocations: 3]; // 3 -> set both for lock screen and home screen dlclose(handle); 

您需要将私有API标头添加到您的项目中。 例如,在这里 ,您通常可以在网上find这些内容。

在上面的示例中,使用3:3的参数调用[SBSUIWallpaperPreviewViewController setWallpaperForLocations:]指示图像应该用于locking和主屏幕。 1只表示locking屏幕。 2仅表示主屏幕。


有关为什么我dynamic打开此框架的解释,请参阅我的相关答案 。

我对铃声没有答案。 这真的应该是一个单独的问题:完全不同的API在工作。