Justin Searls
Justin Searls

Reputation: 4865

How to extract UIBarButtonItem Icons from the iPhone SDK?

I'd like to extract the default UIBarButtonItem icons from the iPhone SDK. I imagine they're probably stored in the iPhoneSimulator platform as alpha-channel-only PNGs, but I've yet to find it.

The one I'm looking for is UIBarButtonSystemItemReply. (For those suspicious that there's even a valid use case for this, I'm looking to use this on a table row header where the user can post replies, row-wise)

Upvotes: 9

Views: 5592

Answers (4)

Nick Frolov
Nick Frolov

Reputation: 1855

This is an old thread, but I found it in Google. I successfully extracted images from UIBarButtonItems initialized with system items, using code below. All the extractor programs were not doing it on iOS 6, or were too complicated for me. Since I only needed 5-6 images, I just got them manually.

- (void)viewDidAppear:(BOOL)animated {

UIView *v1 = self.navigationController.navigationBar;
for (int i = 0; i < v1.subviews.count; i++)
{
    UIView *v2 = [v1.subviews objectAtIndex:i];
    NSLog(@"%i %@", i, [v2 class]);
    if (i == 2)
    {
        for (int j = 0; j < v2.subviews.count; j++)
        {
            UIView *v3 = [v2.subviews objectAtIndex:j];
            NSLog(@"  %i %@", j, [v3 class]);

            if (j == 1)
            {
                // In my test, this view was UIImageView containing button image
                UIImageView *iv = [[UIImageView alloc] initWithImage:((UIImageView *)v3).image];
                [self.view addSubview:iv];
            }
        }
    }
}

}

Upvotes: 0

driggi2
driggi2

Reputation: 171

To copy all iPhone (or MacOS) system icons go to directory:

cd /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/ 

=> there might be more than one iPhoneSimulator version (iPhoneSimulator4.3.sdk), just choose the one you prefer. And than execute following command:

find . -iname "*.png*" -print0 | xargs -I{} -0 cp -v {} /tmp/iPhoneIcons/

/tmp/iPhoneIcons/ => is the destination directory

Upvotes: 17

Simon Woodside
Simon Woodside

Reputation: 7304

The Other.artwork file is in /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/UIKit.framework/ (you need the SDK).

Use the "iPhoneShop-1.3.jar" program -- available currently here to extract all of the images into a directory.

java -jar iPhoneShop-1.3.jar ARTWORK Other.artwork EXPORT Other

Upvotes: 4

AriX
AriX

Reputation: 1687

I don't know how to do this, however I was curious about the same thing a few months ago. You may be able to initialize this UIBarButtonItem and extract the image from it by looping through all of the elements in its UIView and dumping the NSImages. I'm not sure exactly how to go about doing that, but I remember Erica Sadun wrote an article about it regarding using a full-screen camera image. I'm not allowed to add a link to it, so just Google for "erica sadun full screen camera".

Upvotes: 1

Related Questions