本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}