0

I have an iPhone app (does not support Universal) running on iPad mini iOS 8. But I find the icon size in UIActivityViewController is incorrect. How to solve this?

The issue can be reproduced simply initializing a default UIActivityViewController.

UIActivityViewController *avc = [[UIActivityViewController alloc] initWithActivityItems:@[@"hello"] applicationActivities:nil];
[self presentViewController:avc animated:YES completion:nil];

The incorrect behavior is as below: https://drive.google.com/file/d/0B2C5utygT1vHSnlGUzRVdU5YSTA/view?usp=sharing

acyc
  • 1
  • 2

3 Answers3

3

There are 3 things to note here:

  1. image background,
  2. image opaqueness,
  3. image size.

iOS 7

  1. Image background:

Image background should be transparent.

  1. image opaqueness

The "visible part" of the icon should be non transparent aka opaque. Note that any color information won't be preserved:

  1. image size

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.


iOS 8

  1. Image background:

Image background should be white to match the system UIAction icons but you can also use an arbitrary color.

  1. image opaqueness

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.

  1. image size

I am using image with size 240px x 240px, but you can apply custom sized image because system will automatically scale-to-fill image if too small/big.


Wrap up

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

#define isAtLeastiOS8 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)


- (UIImage *)activityImage
{
    if (isAtLeastiOS8)
    {
        return [UIImage imageNamed:@"activity_icon_ios8"];
    }
    else
    {
        return [UIImage imageNamed:@"activity_icon"];
    }
}

Hope that helps!

Credit goes to @damirstuhec

Ahsan Ebrahim Khatri
  • 1,807
  • 1
  • 20
  • 27
  • Thanks for your answer. But the incorrect icons are default icons, and I did not provide image myself. So should I override the default images? – acyc Apr 08 '15 at 10:31
  • can you check any other iPhone application on you iPad if it shows the same behaviour ? – Ahsan Ebrahim Khatri Apr 08 '15 at 10:36
  • if my answer helped you then please mark this as selected :) – Ahsan Ebrahim Khatri Apr 08 '15 at 10:50
  • I just examined, this seems to be an iOS bug. It happens when the app is an iPhone app (does not support universal) but being opened on iPad. I just opened a plain project, which only opens a default UIActivityViewController. And the icons are still enlarged. – acyc Apr 08 '15 at 11:03
  • How about you try some already published iPhone App from AppStore, and install it on your iPad and try it. This will clear the doubts if its the bug in iOS or are we missing something. – Ahsan Ebrahim Khatri Apr 08 '15 at 11:39
  • I cannot address a published app that only support iPhone and also uses UIActivityViewController. But I have a simple app manifesting this issue. https://drive.google.com/file/d/0B2C5utygT1vHT1BLRXROSFFmaFU/view?usp=sharing – acyc Apr 10 '15 at 04:14
0

You might be using the image size that is too big to fit in this area, try using multiple size images with 1x, and 2x and that can fix your problem for example convert the same image into 2 sizes for logo, 30x30 and 60x60 and name them as

30x30 icon goes as -> sampleLogo.png

60x60 icon goes as -> sampleLogo@2x.png

import these in the Images.xcassets under the same name (not two different images) and then try using this.

EDIT : 30x30 and 60x60 are just to give you an idea, also if you Application is compatible with iPhone 6 Plus, then you might also need to use a 3x image that in the given example be 90x90

Ahsan Ebrahim Khatri
  • 1,807
  • 1
  • 20
  • 27
  • Thanks for your answer. But the incorrect icons are default icons, and I did not provide image myself. So should I override the default images? – acyc Apr 08 '15 at 10:31
0

These images need to have a transparent background and I recommend these sizes: // iPadShare@2x should be 126 px, iPadShare should be 53 px, iPhoneShare@2x should be 100 px, and iPhoneShare should be 50 px. I found these sizes to work for what I was making.

Hope this will help :)

  • Hi Arpit, as the image I attached, the wrong icons are iOS default icons: Message, Mail, etc. The images are not provided by my app. – acyc May 06 '15 at 09:00