如何在iPhone中以编程方式设置锁屏,壁纸和铃声?

ios*_*ios 26 iphone objective-c iphone-privateapi ios4 ios

在iPhone中我们是否可以通过编程方式设置锁屏,壁纸和铃声?

如果,那么请告诉我如何设置它们?

Wri*_*sCS 37

这一切都可以轻松完成,但Apple会拒绝.

可以通过改变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;
Run Code Online (Sandbox Code Playgroud)

壁纸可以覆盖:

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";
Run Code Online (Sandbox Code Playgroud)

这些示例用于我的一个Cydia应用程序中.对他们来说并不是更多,但这些应该让你朝着正确的方向前进.

  • 不需要投票.它们在提出问题并且被选为正确答案时有效. (29认同)
  • 壁纸路径不再有效. (2认同)
  • 我不能告诉你新的路径,但我可以告诉你苹果使用新的图像格式.它是一个cpbitmap,所以如果你喜欢tomsave图像,你首先需要将.png或.jpeg转换为.cpbitmap (2认同)