How to get UIImage of AppIcon?

前端 未结 1 1434
灰色年华
灰色年华 2020-12-15 02:45

I am using Assets Catalog, and adding app icon of various size to the assets is okay.

But when I tried to get the UIImage programmatically, it returned nil.

相关标签:
1条回答
  • 2020-12-15 03:34

    The problem is that the AppIcon from the asset catalog is not placed in the the catalog after compiling. Instated it it copied into your apps bundle, just like before.

    The name conversion used when copying the icon to the app bundle is AppIcon<size>.png, where the size is for example 40x40 or 72x72

    You can get your apps icons by specifying the size of the app icon you want:

    UIImage *appIcon = [UIImage imageNamed:@"AppIcon40x40"];
    
    0 讨论(0)
提交回复
热议问题