googleads-consent-sdk-ios
googleads-consent-sdk-ios copied to clipboard
App icon without round corners on iOS
Apple recommends to use app icon without round corners.
[UIImage imageNamed:iconName]; loads and displays the rectangular icon. That doesn't look nice.
I would use this code to make the corners round. It's not the orignal rounding of Apple, but it looks better than rectangle.
/// Returns an icon with rounded corners.
static UIImage * roundCornerIcon(UIImage * icon)
{
CGSize size = CGSizeMake(icon.size.width*icon.scale, icon.size.height *icon.scale);
UIGraphicsBeginImageContextWithOptions(size, NO, 1.0);
float radius = size.width * 0.25;
[[UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, size.width, size.height)
cornerRadius:radius] addClip];
[icon drawInRect:CGRectMake(0, 0, size.width, size.height)];
UIImage * roundCornerIcon = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return roundCornerIcon;
}
/// Returns the application's icon as a data URI string.
static NSString *_Nonnull PACIconDataURIString(void) {
NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
NSArray<NSString *> *iconFiles =
infoDictionary[@"CFBundleIcons"][@"CFBundlePrimaryIcon"][@"CFBundleIconFiles"];
NSString *iconName = iconFiles.lastObject;
if (!iconName) {
return @"";
}
UIImage *iconImage = roundCornerIcon([UIImage imageNamed:iconName]);
NSData *iconData = UIImagePNGRepresentation(iconImage);
NSString *iconBase64String = [iconData base64EncodedStringWithOptions:0];
return [@"data:image/png;base64," stringByAppendingString:iconBase64String];
}
Here is the comparison. Rectangle vs rounded.
nice solution! I agree they should add this