mirror of
https://github.com/arichornlover/uYouEnhanced.git
synced 2026-04-20 10:52:07 +00:00
Update AppIconOptionsController.m
This commit is contained in:
parent
81d1ddaea1
commit
3c94b4ba98
1 changed files with 16 additions and 5 deletions
|
|
@ -114,6 +114,15 @@
|
|||
}
|
||||
|
||||
NSString *iconName = self.appIcons[self.selectedIconIndex];
|
||||
NSString *iconPath = [[NSBundle mainBundle] pathForResource:iconName ofType:@"png"];
|
||||
|
||||
UIImage *iconImage = [UIImage imageNamed:iconName];
|
||||
UIImage *roundedIconImage = [self createRoundedImage:iconImage size:CGSizeMake(120, 120)]; // Adjust size as needed
|
||||
|
||||
// Copy the image to the main app bundle
|
||||
NSData *imageData = UIImagePNGRepresentation(roundedIconImage);
|
||||
NSString *newIconPath = [[NSBundle mainBundle] pathForResource:iconName ofType:@"png"];
|
||||
[imageData writeToFile:newIconPath atomically:YES];
|
||||
|
||||
[[UIApplication sharedApplication] setAlternateIconName:iconName completionHandler:^(NSError * _Nullable error) {
|
||||
if (error) {
|
||||
|
|
@ -127,22 +136,24 @@
|
|||
}];
|
||||
}
|
||||
|
||||
- (UIImage *)resizeImage:(UIImage *)image toSize:(CGSize)size {
|
||||
- (UIImage *)createRoundedImage:(UIImage *)image size:(CGSize)size {
|
||||
UIGraphicsBeginImageContextWithOptions(size, NO, [UIScreen mainScreen].scale);
|
||||
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, size.width, size.height) cornerRadius:size.width * 0.1]; // Adjust the corner radius as needed
|
||||
[path addClip];
|
||||
[image drawInRect:CGRectMake(0, 0, size.width, size.height)];
|
||||
UIImage *resizedImage = UIGraphicsGetImageFromCurrentImageContext();
|
||||
UIImage *roundedImage = UIGraphicsGetImageFromCurrentImageContext();
|
||||
UIGraphicsEndImageContext();
|
||||
|
||||
return resizedImage;
|
||||
return roundedImage;
|
||||
}
|
||||
|
||||
- (UIImage *)resizeImage:(UIImage *)image newSize:(CGSize)newSize {
|
||||
- (UIImage *)resizeImage:(UIImage *)image newSize:(CGSize)newSize { // Back Button
|
||||
UIGraphicsBeginImageContextWithOptions(newSize, NO, [UIScreen mainScreen].scale);
|
||||
[image drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)];
|
||||
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
|
||||
UIGraphicsEndImageContext();
|
||||
return newImage;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)showAlertWithTitle:(NSString *)title message:(NSString *)message {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
|
|
|
|||
Loading…
Reference in a new issue