コード例 #1
0
        public static UIImage ToImage(this AtlassianIcon @this, nfloat size, bool cache = true)
        {
            var cacheDir = NSFileManager.DefaultManager.GetUrls(NSSearchPathDirectory.CachesDirectory, NSSearchPathDomain.User)[0].Path;

            string extension = string.Empty;

            if (Scale > 1 && Scale < 3)
            {
                extension = "@2x";
            }
            else if (Scale >= 3)
            {
                extension = "@3x";
            }

            var fileName     = string.Format("atlassian-{0}-{1}{2}.png", (int)@this.CharacterCode, size, extension);
            var combinedPath = Path.Combine(cacheDir, fileName);

            if (File.Exists(combinedPath))
            {
                var img = cache ? UIImage.FromBundle(combinedPath) : UIImage.FromFile(combinedPath);
                return(img.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate));
            }
            else
            {
                var img = Graphics.ImageFromFont(UIFont.FromName("Atlassian-icons", size), @this.CharacterCode, UIColor.Black);
                if (img == null)
                {
                    return(null);
                }
                var pngData = img.AsPNG();
                pngData.Save(combinedPath, false);
                return(img.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate));
            }
        }
コード例 #2
0
 public static UIImage ToEmptyListImage(this AtlassianIcon @this)
 {
     return(@this.ToImage(64f, false));
 }
コード例 #3
0
 public static UIImage ToImage(this AtlassianIcon @this, bool cache = true)
 {
     return(@this.ToImage(22f, cache));
 }