Open 6ag opened 8 years ago
- (id)getWallPaperVCWithImage:(UIImage *)image
{
Class wallPaperClass = NSClassFromString(@"PLStaticWallpaperImageViewController");
id wallPaperInstance = [[wallPaperClass alloc] performSelector:NSSelectorFromString(@"initWithUIImage:") withObject:image];
[wallPaperInstance setValue:@(YES) forKeyPath:@"saveWallpaperData"];
return wallPaperInstance;
}
- (void)saveAndAsScreenPhotoWithImage:(UIImage *)image imageScreen:(UIImageScreen)imageScreen finished:(void (^)(BOOL success))finished
{
[PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
if (PHAuthorizationStatusAuthorized == status) {
// 保存需要设置为壁纸的图片到相册
UIImageWriteToSavedPhotosAlbum(image, nil,nil, NULL);
// 获取壁纸控制器
id wallPaperVc = [self getWallPaperVCWithImage:image];
if (wallPaperVc) {
switch (imageScreen) {
case UIImageScreenHome:
{
if (self.on) {
[wallPaperVc performSelector:NSSelectorFromString(@"setImageAsHomeScreenClicked:") withObject:image];
}
}
break;
case UIImageScreenLock:
{
if (self.on) {
[wallPaperVc performSelector:NSSelectorFromString(@"setImageAsLockScreenClicked:") withObject:image];
}
}
break;
case UIImageScreenBoth:
{
if (self.on) {
[wallPaperVc performSelector:NSSelectorFromString(@"setImageAsHomeScreenAndLockScreenClicked:") withObject:image];
}
}
break;
default:
break;
}
finished(YES);
} else {
finished(NO);
}
} else {
// 无权限
finished(NO);
}
}];
}
Can you help me?
+1
Apple now requires the SpringBoard or Photos entitlement for updating the wallpaper. Therefore it is impossible to do this even with private api’s.
i am unable to add file PLStaticWallpaperImageViewController. When i add by framework it shows linker error please help
I can use the class
PLStaticWallpaperImageViewController
on iOS9.x.x. But after the upgrade iOS10 not be able to do so.