簡體   English   中英

如何從iPhone SDK中提取UIBarButtonItem圖標?

[英]How to extract UIBarButtonItem Icons from the iPhone SDK?

我想從iPhone SDK中提取默認的UIBarButtonItem圖標。 我想他們可能只是作為alpha-channel-only PNG存儲在iPhoneSimulator平台上,但我還沒有找到它。

我正在尋找的是UIBarButtonSystemItemReply。 (對於那些可疑的,甚至有一個有效的用例,我希望在用戶可以發布回復的表行標題上使用它,行方式)

要復制所有iPhone(或MacOS)系統圖標,請轉到目錄:

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

=>可能有多個iPhoneSimulator版本(iPhoneSimulator4.3.sdk),只需選擇您喜歡的版本。 然后執行以下命令:

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

/tmp/iPhoneIcons/ =>是目標目錄

Other.artwork文件位於/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/UIKit.framework/(您需要SDK)。

使用“iPhoneShop-1.3.jar”程序 - 此處目前可用於將所有圖像提取到目錄中。

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

我不知道該怎么做,但幾個月前我對同樣的事感到好奇。 您可以初始化此UIBarButtonItem並通過循環遍歷其UIView中的所有元素並轉儲NSImages來從中提取圖像。 我不確定該如何去做,但我記得Erica Sadun寫了一篇關於使用全屏相機圖像的文章。 我不允許添加鏈接,所以只有Google為“erica sadun全屏相機”。

這是一個老線程,但我在谷歌找到了它。 我使用下面的代碼成功從使用系統項初始化的UIBarButtonItem中提取了圖像。 所有的提取器程序都沒有在iOS 6上運行,或者對我來說太復雜了。 由於我只需要5-6張圖像,我只是手動獲取它們。

- (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];
            }
        }
    }
}

}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM