5

I have created a subclass of UIActivity to present a custom activity on the Activity Sheet within my app. However I cannot get it to show my icon.

I have tried a few different images at typical icon sizes, e.g.:

- (UIImage *)activityImage { 
    return [UIImage imageNamed:@"my_app_icon.png"]; 
}

but I just get a gray square and my icon does not show at all.

EDIT: the real problem was that my XCode docs were out of date, so I did not have the information that the maximum image size is very limited.

Bryan
  • 11,398
  • 3
  • 53
  • 78
  • This is an old question but was your image able to have color or was it gray? I'm having the same issue but I'm using the recommended sizes on the apple docs – Andrew Park Dec 05 '13 at 19:32
  • Only Apple built-in activities (like Mail) are in color; your own activities have to be gray. The documentation now explains exactly what happens to the image you supply: https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIActivity_Class/Reference/Reference.html#//apple_ref/occ/instm/UIActivity/activityImage. – Bryan Dec 08 '13 at 09:15

1 Answers1

5

It doesn't look like you can set a background image to your UIActivity. According to the official doc: any color data in the image itself is ignored only the alpha is taken in account to act as a mask.

tiguero
  • 11,477
  • 5
  • 43
  • 61
  • Are you thinking of UIActivityIndicator now? – Bryan Sep 25 '12 at 23:27
  • Your first answer was actually useful, in that the doc link is newer than the docs that XCode is showing me, and I didn't have the pixel size limits. Pass a much smaller image, and it works. – Bryan Sep 25 '12 at 23:29
  • And sorry for mentioning the UIActivityIndicator i believe that's not what u want actually – tiguero Sep 25 '12 at 23:38
  • Yes, it takes my image as a mask and not a full-color icon. When I asked the question my problem was that it wasn't using my icon at all, because it was too big. I will accept your answer since it helped me find the right solution. – Bryan Sep 27 '12 at 11:39