I am trying to add a custom UIActivity
of type UIActivityCategoryAction
to UIActivityController
. But in iOS 8, all of them are appearing with a black background.
Is there a way to change this?
I am trying to add a custom UIActivity
of type UIActivityCategoryAction
to UIActivityController
. But in iOS 8, all of them are appearing with a black background.
Is there a way to change this?
There are 3 things to note here:
Image background should be transparent.
The "visible part" of the icon should be non transparent aka opaque. Note that any color information won't be preserved:
Because the image won't be scaled by the system if too small/big, you have to provide appropriately sized image. I found image size 120px x 120px
to fit perfectly.
Note: this size also takes icon padding into account.
Image background should be white to match the system UIAction
icons but you can also use an arbitrary color.
Same as in iOS 7, "visible" part of the icon should be non transparent aka opaque, however in iOS 8+ color information will be preserved.
I am using image with size 240px x 240px
, but you can apply custom sized image because system will automatically scalle-to-fill image if too small/big.
That said, if you want to support both iOS 7 and iOS 8+, you have to have 2 versions of custom UIActivity
icon image.
For iOS 7 you should use 120px x 120px sized image with transparent background. Note: find the size that best suits your needs.
For iOS 8+ you should use custom sized square image with white background and "visible" part of an arbitrary colour.
Code example
- (UIImage *)activityImage
{
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) {
return [UIImage imageNamed:@"activity_icon_ios8"];
}
else {
return [UIImage imageNamed:@"activity_icon"];
}
}
Hope that helps!
UIActivityController
. At least for now. –
Negris activitySettingsImage
, but it's undocumented at this moment –
Concavity © 2022 - 2024 — McMap. All rights reserved.