Update AppIconOptionsController.m

This commit is contained in:
arichornlover 2024-06-13 19:15:40 -05:00 committed by GitHub
parent 26b8ca0a95
commit 9de3ac645e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -89,7 +89,7 @@
- (UIImage *)appIconPreviewForIconName:(NSString *)iconName {
NSDictionary *iconData = self.alternateIcons[iconName];
NSArray *iconFiles = iconData[@"CFBundleIconFiles"];
NSString iconFile = iconFiles[0];
NSString *iconFile = iconFiles[0];
UIImage *iconImage = [UIImage imageNamed:iconFile];
UIImage *roundedIconImage = [self createRoundedImage:iconImage size:CGSizeMake(120, 120)];
@ -97,6 +97,22 @@
return roundedIconImage;
}
- (UIImage *)createRoundedImage:(UIImage *)image size:(CGSize)size {
UIGraphicsImageRenderer *renderer = [[UIGraphicsImageRenderer alloc] initWithSize:size];
return [renderer imageWithActions:^(UIGraphicsImageRendererContext *context) {
UIBezierPath *roundPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, size.width, size.height) cornerRadius:size.width / 2.0];
[roundPath addClip];
[image drawInRect:CGRectMake(0, 0, size.width, size.height)];
}];
}
- (UIImage *)resizeImage:(UIImage *)image newSize:(CGSize)newSize {
UIGraphicsImageRenderer *renderer = [[UIGraphicsImageRenderer alloc] initWithSize:newSize];
return [renderer imageWithActions:^(UIGraphicsImageRendererContext *context) {
[image drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)];
}];
}
- (void)showAlertWithTitle:(NSString *)title message:(NSString *)message {
dispatch_async(dispatch_get_main_queue(), ^{
UIAlertController *alert = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];