當前位置: 首頁>>代碼示例>>C#>>正文


C# UIColor.SetFill方法代碼示例

本文整理匯總了C#中UIKit.UIColor.SetFill方法的典型用法代碼示例。如果您正苦於以下問題:C# UIColor.SetFill方法的具體用法?C# UIColor.SetFill怎麽用?C# UIColor.SetFill使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在UIKit.UIColor的用法示例。


在下文中一共展示了UIColor.SetFill方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ImageFromFont

        public static UIImage ImageFromFont(string text, UIColor iconColor, CGSize iconSize, string fontName)
        {
            UIGraphics.BeginImageContextWithOptions(iconSize, false, 0);

              var textRect = new CGRect(CGPoint.Empty, iconSize);
              var path = UIBezierPath.FromRect(textRect);
              UIColor.Clear.SetFill();
              path.Fill();

              var font = UIFont.FromName(fontName, iconSize.Width);
              using (var label = new UILabel() { Text = text, Font = font })
              {
            GetFontSize(label, iconSize, 500, 5);
            font = label.Font;
              }
              iconColor.SetFill();
              using (var nativeString = new NSString(text))
              {
            nativeString.DrawString(textRect, new UIStringAttributes
              {
            Font = font,
            ForegroundColor = iconColor,
            BackgroundColor = UIColor.Clear,
            ParagraphStyle = new NSMutableParagraphStyle
            {
              Alignment = UITextAlignment.Center
            }
              });
              }
              var image = UIGraphics.GetImageFromCurrentImageContext();
              UIGraphics.EndImageContext();
              image = image.ImageWithRenderingMode (UIImageRenderingMode.AlwaysOriginal);
              return image;
        }
開發者ID:anthonylowther21,項目名稱:DebtCalculator,代碼行數:34,代碼來源:FontAwesomeImageHelper.cs

示例2: CreateBackgroundImage

 private static UIImage CreateBackgroundImage(UIColor color)
 {
     UIGraphics.BeginImageContext(new CoreGraphics.CGSize(1, 1f));
     color.SetFill();
     UIGraphics.RectFill(new CoreGraphics.CGRect(0, 0, 1, 1));
     var img = UIGraphics.GetImageFromCurrentImageContext();
     UIGraphics.EndImageContext();
     return img;
 }
開發者ID:Mikoj,項目名稱:CodeBucket,代碼行數:9,代碼來源:Theme.cs

示例3: RenderSolidImage

		static UIImage RenderSolidImage(UIColor color, CGSize size)
		{
			UIGraphics.BeginImageContextWithOptions (size, false, 0);
			CGContext context = UIGraphics.GetCurrentContext ();
			color.SetFill ();
			context.FillRect (new CGRect (CGPoint.Empty, size));
			UIImage result = UIGraphics.GetImageFromCurrentImageContext ();
			UIGraphics.EndImageContext ();
			return result;
		}
開發者ID:richardboegli,項目名稱:KinderChat,代碼行數:10,代碼來源:ImageUtils.cs

示例4: ImageFromFont

        public static UIImage ImageFromFont(UIFont font, char character, UIColor fillColor)
        {
            var s = new NSString("" + character);
            var stringSize = s.StringSize(font);
            var maxSize = (nfloat)Math.Max(stringSize.Height, stringSize.Width);
            var size = new CGSize(maxSize, maxSize);

            UIGraphics.BeginImageContextWithOptions(size, false, 0f);
            fillColor.SetFill();

            var drawPoint = new CGPoint((size.Width / 2f) - (stringSize.Width / 2f),
                                (size.Height / 2f) - (stringSize.Height / 2f));
            s.DrawString(drawPoint, font);

            var img = UIGraphics.GetImageFromCurrentImageContext();
            UIGraphics.EndImageContext();
            return img;
        }
開發者ID:jianwoo,項目名稱:CodeHub,代碼行數:18,代碼來源:Graphics.cs

示例5: Tint

        public static UIImage Tint(this UIImage img, UIColor tint, CGBlendMode blendMode) {
            UIGraphics.BeginImageContextWithOptions(img.Size, false, 0f);
            tint.SetFill();
            var bounds = new CGRect(0, 0, img.Size.Width, img.Size.Height);
            UIGraphics.RectFill(bounds);

            img.Draw(bounds, blendMode, 1f);

            if (blendMode != CGBlendMode.DestinationIn)
                img.Draw(bounds, CGBlendMode.DestinationIn, 1f);

            var tintedImage = UIGraphics.GetImageFromCurrentImageContext();
            UIGraphics.EndImageContext();

            return tintedImage;
        }
開發者ID:rmawani,項目名稱:Awesomizer,代碼行數:16,代碼來源:UIViewExtensions.cs

示例6: CircleImageWithColor

    // private methods

    UIImage CircleImageWithColor(UIColor color, nfloat height)
    {
        UIGraphics.BeginImageContextWithOptions(new CGSize(height, height), false, 0);
        CGColorSpace colorSpace = CGColorSpace.CreateDeviceRGB();

        UIBezierPath fillPath = UIBezierPath.FromOval(new CGRect(0, 0, height, height));
        color.SetFill();
        fillPath.Fill();

        UIImage dotImage = UIGraphics.GetImageFromCurrentImageContext();
        UIGraphics.EndImageContext();

        return dotImage;
    }
開發者ID:markerpen,項目名稱:PulsingAnnotationView,代碼行數:16,代碼來源:PulsingAnnotationView.cs


注:本文中的UIKit.UIColor.SetFill方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。