How to get the current application icon in ios

后端 未结 9 2095
心在旅途
心在旅途 2020-12-09 03:05

Is there a way to get the current application icon in a cocoa-touch app? Thank you.

9条回答
  •  感动是毒
    2020-12-09 03:24

    If you're using Xamarin:

    var iconNames = NSBundle.MainBundle.InfoDictionary.ValueForKeyPath((NSString)"CFBundleIcons.CFBundlePrimaryIcon.CFBundleIconFiles") as NSArray;
    var name = iconNames.GetItem(iconNames.Count - 1); //Grabs last item, call with 0 for the first item
    var icon = UIImage.FromBundle(name);
    

    Based on Andy's answer using the KVC method. Bit lengthy, but using KeyPath is better than chaining calls to ValueForKey.

提交回复
热议问题