本文整理汇总了C#中UIColor.SetFill方法的典型用法代码示例。如果您正苦于以下问题:C# UIColor.SetFill方法的具体用法?C# UIColor.SetFill怎么用?C# UIColor.SetFill使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UIColor
的用法示例。
在下文中一共展示了UIColor.SetFill方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CircularImageWithColor
public static UIImage CircularImageWithColor(UIColor color, SizeF size){
var rect = new RectangleF(0,0, size.Width, size.Height);
var circle = UIBezierPath.FromOval (rect);
UIGraphics.BeginImageContextWithOptions (rect.Size, false, 0f);
color.SetFill ();
color.SetStroke ();
circle.AddClip ();
circle.Fill ();
circle.Stroke ();
var image = UIGraphics.GetImageFromCurrentImageContext ();
UIGraphics.EndImageContext ();
return image;
}
示例2: ImageWithColor
public static UIImage ImageWithColor (UIColor imageColor, float cornerRadius)
{
float minEdgeSize = EdgeSizeFromCornerRadius (cornerRadius);
RectangleF rect = new RectangleF (0, 0, minEdgeSize, minEdgeSize);
UIBezierPath roundedRect = UIBezierPath.FromRoundedRect (rect, cornerRadius);
roundedRect.LineWidth = 0;
UIGraphics.BeginImageContextWithOptions (rect.Size, false, 0.0f);
imageColor.SetFill ();
roundedRect.Fill ();
roundedRect.Stroke ();
roundedRect.AddClip ();
UIImage image = UIGraphics.GetImageFromCurrentImageContext ();
UIGraphics.EndImageContext ();
return image.CreateResizableImage (new UIEdgeInsets (cornerRadius, cornerRadius, cornerRadius, cornerRadius));
}
示例3: ImageWithColor
public UIImage ImageWithColor(UIColor color)
{
// Color Ball
UIImage img = new UIImage(Config.PIN_COLOR);
// begin a new image context, to draw our colored image onto
UIGraphics.BeginImageContextWithOptions(img.Size, false, UIScreen.MainScreen.Scale);
// get a reference to that context we created
CGContext context = UIGraphics.GetCurrentContext();
// set the fill color
color.SetFill();
// translate/flip the graphics context (for transforming from CG* coords to UI* coords
context.TranslateCTM(0, img.Size.Height);
context.ScaleCTM(1.0f, -1.0f);
// set the blend mode, and the original image
context.SetBlendMode(CGBlendMode.Normal);
RectangleF rect = new RectangleF(0, 0, img.Size.Width, img.Size.Height);
context.DrawImage(rect, img.CGImage);
// set a mask that matches the shape of the image
context.ClipToMask(rect, img.CGImage);
context.AddRect(rect);
context.DrawPath(CGPathDrawingMode.Fill);
// generate a new UIImage from the graphics context we drew onto
UIImage coloredImg = UIGraphics.GetImageFromCurrentImageContext();
// End
UIGraphics.EndImageContext();
return coloredImg;
}
示例4: DrawRect
//.........这里部分代码省略.........
new PointF (frame.GetMinX() + 0.28684F * frame.Width, frame.GetMinY() + 0.60718F * frame.Height),
new PointF (frame.GetMinX() + 0.30556F * frame.Width, frame.GetMinY() + 0.60378F * frame.Height),
new PointF (frame.GetMinX() + 0.29644F * frame.Width, frame.GetMinY() + 0.60718F * frame.Height));
mmShapePath.AddCurveToPoint (
new PointF (frame.GetMinX() + 0.26125F * frame.Width, frame.GetMinY() + 0.59752F * frame.Height),
new PointF (frame.GetMinX() + 0.27718F * frame.Width, frame.GetMinY() + 0.60718F * frame.Height),
new PointF (frame.GetMinX() + 0.26808F * frame.Width, frame.GetMinY() + 0.60378F * frame.Height));
mmShapePath.AddCurveToPoint (
new PointF (frame.GetMinX() + 0.26125F * frame.Width, frame.GetMinY() + 0.55093F * frame.Height),
new PointF (frame.GetMinX() + 0.24715F * frame.Width, frame.GetMinY() + 0.58467F * frame.Height),
new PointF (frame.GetMinX() + 0.24715F * frame.Width, frame.GetMinY() + 0.56377F * frame.Height));
mmShapePath.AddLineTo (new PointF (frame.GetMinX() + 0.57377F * frame.Width, frame.GetMinY() + 0.26601F * frame.Height));
mmShapePath.AddCurveToPoint (
new PointF (frame.GetMinX() + 0.57380F * frame.Width, frame.GetMinY() + 0.10041F * frame.Height),
new PointF (frame.GetMinX() + 0.62368F * frame.Width, frame.GetMinY() + 0.22029F * frame.Height),
new PointF (frame.GetMinX() + 0.62368F * frame.Width, frame.GetMinY() + 0.14606F * frame.Height));
mmShapePath.AddCurveToPoint (
new PointF (frame.GetMinX() + 0.48291F * frame.Width, frame.GetMinY() + 0.06617F * frame.Height),
new PointF (frame.GetMinX() + 0.54946F * frame.Width, frame.GetMinY() + 0.07832F * frame.Height),
new PointF (frame.GetMinX() + 0.51721F * frame.Width, frame.GetMinY() + 0.06617F * frame.Height));
mmShapePath.AddCurveToPoint (
new PointF (frame.GetMinX() + 0.39208F * frame.Width, frame.GetMinY() + 0.10040F * frame.Height),
new PointF (frame.GetMinX() + 0.44863F * frame.Width, frame.GetMinY() + 0.06617F * frame.Height),
new PointF (frame.GetMinX() + 0.41637F * frame.Width, frame.GetMinY() + 0.07832F * frame.Height));
mmShapePath.AddLineTo (new PointF (frame.GetMinX() + 0.07956F * frame.Width, frame.GetMinY() + 0.38530F * frame.Height));
mmShapePath.AddCurveToPoint (
new PointF (frame.GetMinX() + 0.05400F * frame.Width, frame.GetMinY() + 0.39496F * frame.Height),
new PointF (frame.GetMinX() + 0.07274F * frame.Width, frame.GetMinY() + 0.39149F * frame.Height),
new PointF (frame.GetMinX() + 0.06365F * frame.Width, frame.GetMinY() + 0.39496F * frame.Height));
mmShapePath.AddCurveToPoint (
new PointF (frame.GetMinX() + 0.02841F * frame.Width, frame.GetMinY() + 0.38530F * frame.Height),
new PointF (frame.GetMinX() + 0.04434F * frame.Width, frame.GetMinY() + 0.39496F * frame.Height),
new PointF (frame.GetMinX() + 0.03525F * frame.Width, frame.GetMinY() + 0.39149F * frame.Height));
mmShapePath.AddCurveToPoint (
new PointF (frame.GetMinX() + 0.02841F * frame.Width, frame.GetMinY() + 0.33867F * frame.Height),
new PointF (frame.GetMinX() + 0.01434F * frame.Width, frame.GetMinY() + 0.37241F * frame.Height),
new PointF (frame.GetMinX() + 0.01434F * frame.Width, frame.GetMinY() + 0.35151F * frame.Height));
mmShapePath.AddLineTo (new PointF (frame.GetMinX() + 0.34095F * frame.Width, frame.GetMinY() + 0.05378F * frame.Height));
mmShapePath.AddCurveToPoint (
new PointF (frame.GetMinX() + 0.48291F * frame.Width, frame.GetMinY() + 0.00013F * frame.Height),
new PointF (frame.GetMinX() + 0.37888F * frame.Width, frame.GetMinY() + 0.01919F * frame.Height),
new PointF (frame.GetMinX() + 0.42931F * frame.Width, frame.GetMinY() + 0.00013F * frame.Height));
mmShapePath.AddCurveToPoint (
new PointF (frame.GetMinX() + 0.62491F * frame.Width, frame.GetMinY() + 0.05378F * frame.Height),
new PointF (frame.GetMinX() + 0.53657F * frame.Width, frame.GetMinY() + 0.00013F * frame.Height),
new PointF (frame.GetMinX() + 0.58700F * frame.Width, frame.GetMinY() + 0.01919F * frame.Height));
mmShapePath.AddCurveToPoint (
new PointF (frame.GetMinX() + 0.68292F * frame.Width, frame.GetMinY() + 0.19950F * frame.Height),
new PointF (frame.GetMinX() + 0.66705F * frame.Width, frame.GetMinY() + 0.09219F * frame.Height),
new PointF (frame.GetMinX() + 0.68815F * frame.Width, frame.GetMinY() + 0.14529F * frame.Height));
mmShapePath.AddLineTo (new PointF (frame.GetMinX() + 0.68143F * frame.Width, frame.GetMinY() + 0.21454F * frame.Height));
mmShapePath.AddLineTo (new PointF (frame.GetMinX() + 0.69786F * frame.Width, frame.GetMinY() + 0.21318F * frame.Height));
mmShapePath.AddCurveToPoint (
new PointF (frame.GetMinX() + 0.71580F * frame.Width, frame.GetMinY() + 0.21244F * frame.Height),
new PointF (frame.GetMinX() + 0.70379F * frame.Width, frame.GetMinY() + 0.21269F * frame.Height),
new PointF (frame.GetMinX() + 0.70984F * frame.Width, frame.GetMinY() + 0.21244F * frame.Height));
mmShapePath.AddCurveToPoint (
new PointF (frame.GetMinX() + 0.85774F * frame.Width, frame.GetMinY() + 0.26604F * frame.Height),
new PointF (frame.GetMinX() + 0.76941F * frame.Width, frame.GetMinY() + 0.21244F * frame.Height),
new PointF (frame.GetMinX() + 0.81981F * frame.Width, frame.GetMinY() + 0.23147F * frame.Height));
mmShapePath.AddCurveToPoint (
new PointF (frame.GetMinX() + 0.85774F * frame.Width, frame.GetMinY() + 0.52485F * frame.Height),
new PointF (frame.GetMinX() + 0.93599F * frame.Width, frame.GetMinY() + 0.33738F * frame.Height),
new PointF (frame.GetMinX() + 0.93599F * frame.Width, frame.GetMinY() + 0.45349F * frame.Height));
mmShapePath.AddLineTo (new PointF (frame.GetMinX() + 0.54521F * frame.Width, frame.GetMinY() + 0.80977F * frame.Height));
mmShapePath.AddCurveToPoint (
new PointF (frame.GetMinX() + 0.51965F * frame.Width, frame.GetMinY() + 0.81940F * frame.Height),
new PointF (frame.GetMinX() + 0.53840F * frame.Width, frame.GetMinY() + 0.81600F * frame.Height),
new PointF (frame.GetMinX() + 0.52930F * frame.Width, frame.GetMinY() + 0.81940F * frame.Height));
mmShapePath.AddLineTo (new PointF (frame.GetMinX() + 0.51965F * frame.Width, frame.GetMinY() + 0.81940F * frame.Height));
mmShapePath.ClosePath ();
context.SaveState ();
context.SetShadowWithColor (mmDropShadowOffset, mmDropShadowBlurRadius, mmDropShadow.CGColor);
context.SetBlendMode (CGBlendMode.Overlay);
mmFill.SetFill ();
mmShapePath.Fill ();
RectangleF mmShapeBorderRect = RectangleF.Inflate (mmShapePath.Bounds, mmInnerShadowBlurRadius, mmInnerShadowBlurRadius);
mmShapeBorderRect.Offset (mmInnerShadowOffset.Width, mmInnerShadowOffset.Height);
mmShapeBorderRect.UnionWith (mmShapePath.Bounds);
UIBezierPath mmShapeNegativePath = UIBezierPath.FromRect (mmShapeBorderRect);
mmShapeNegativePath.AppendPath (mmShapePath);
mmShapeNegativePath.UsesEvenOddFillRule = true;
context.SaveState ();
{
Single xOffset = mmInnerShadowOffset.Width + (float) Math.Round (mmShapeBorderRect.Size.Width);
Single yOffset = mmInnerShadowOffset.Height;
context.SetShadowWithColor (new SizeF (xOffset + CopySign (0.1F, xOffset), yOffset + CopySign (0.1F, yOffset)), mmInnerShadowBlurRadius, mmInnerShadow.CGColor);
mmShapePath.AddClip ();
CGAffineTransform transform = CGAffineTransform.MakeTranslation ((float)-Math.Round (mmShapeBorderRect.Size.Width), 0F);
mmShapeNegativePath.ApplyTransform (transform);
UIColor.Gray.SetFill ();
mmShapeNegativePath.Fill ();
}
context.RestoreState ();
context.RestoreState ();
}
}
示例5: BackButtonImage
public static UIImage BackButtonImage(UIColor color, UIBarMetrics metrics, float cornerRadius, UIColor borderColor, float borderWidth)
{
SizeF size;
if (metrics.Equals(UIBarMetrics.Default))
size = new SizeF(50, 30);
else
size = new SizeF(60, 23);
UIBezierPath fillPath = BezierPathForBackButton(new RectangleF(0, 0, size.Width, size.Height), cornerRadius);
fillPath.LineWidth = 2 * borderWidth;
UIGraphics.BeginImageContextWithOptions(size, false, 0f);
color.SetFill();
borderColor.SetStroke();
fillPath.AddClip();
fillPath.Fill();
if (borderWidth > 0)
fillPath.Stroke();
UIImage image = UIGraphics.GetImageFromCurrentImageContext();
UIGraphics.EndImageContext();
return image.CreateResizableImage(new UIEdgeInsets(cornerRadius, 15f, cornerRadius, cornerRadius), UIImageResizingMode.Stretch);
}
示例6: Image
public static UIImage Image(UIColor color, float cornerRadius, UIColor borderColor, float borderWidth)
{
float minEdgeSize = EdgeSize(cornerRadius);
RectangleF rect = new RectangleF(0, 0, minEdgeSize, minEdgeSize);
UIBezierPath fillPath = UIBezierPath.FromRoundedRect(rect, cornerRadius);
UIBezierPath strokePath = fillPath;
if (borderWidth > 0)
{
RectangleF insetRect = RectangleF.Inflate(rect, -1 * borderWidth / 2, -1 * borderWidth / 2);
strokePath = UIBezierPath.FromRoundedRect(insetRect, cornerRadius);
}
UIGraphics.BeginImageContextWithOptions(rect.Size, false, 0f);
color.SetFill();
borderColor.SetStroke();
fillPath.Fill();
if (borderWidth > 0)
strokePath.Stroke();
fillPath.AddClip();
UIImage image = UIGraphics.GetImageFromCurrentImageContext();
UIGraphics.EndImageContext();
return image.CreateResizableImage(new UIEdgeInsets(cornerRadius, cornerRadius, cornerRadius, cornerRadius), UIImageResizingMode.Stretch);
}
示例7: ThumbWithColor
public UIImage ThumbWithColor(UIColor color)
{
float scale = UIScreen.MainScreen.Scale;
if (scale < 1)
{
scale = 1;
}
SizeF size = new SizeF (68 * scale, 44 * scale);
float radius = 10 * scale;
// create a new bitmap image context
UIGraphics.BeginImageContext(size);
// get context
CGContext context = UIGraphics.GetCurrentContext();
// push context to make it current
// (need to do this manually because we are not drawing in a UIView)
UIGraphics.PushContext(context);
color.SetFill();
UIColor.Black.ColorWithAlpha(0.8f).SetStroke();
float radiusp = radius + 0.5f;
float wid1 = size.Width - 0.5f;
float hei1 = size.Height - 0.5f;
float wid2 = size.Width - radiusp;
float hei2 = size.Height - radiusp;
// Path
context.MoveTo(0.5f, radiusp);
context.AddArcToPoint(0.5f, 0.5f, radiusp, 0.5f, radius);
context.AddLineToPoint(wid2, 0.5f);
context.AddArcToPoint(wid1, 0.5f, wid1, radiusp, radius);
context.AddLineToPoint(wid1, hei2);
context.AddArcToPoint(wid1, hei1, wid2, hei1, radius);
context.AddLineToPoint(radius, hei1);
context.AddArcToPoint(0.5f, hei1, 0.5f, hei2, radius);
context.ClosePath();
context.DrawPath(CGPathDrawingMode.FillStroke);
// Arrow
UIColor.White.ColorWithAlpha(0.6f).SetFill();
UIColor.Black.ColorWithAlpha(0.3f).SetStroke();
float[] points = new float[8]
{
(19 * scale) + 0.5f,
(16 * scale) + 0.5f,
(36 * scale) + 0.5f,
(10 * scale) + 0.5f,
(52 * scale) + 0.5f,
(22 * scale) + 0.5f,
(34 * scale) + 0.5f,
(28 * scale) + 0.5f
};
context.MoveTo(points[0], points[1]);
context.AddLineToPoint(points[2], points[1]);
context.AddLineToPoint(points[2], points[3]);
context.AddLineToPoint(points[4], points[5]);
context.AddLineToPoint(points[2], points[6]);
context.AddLineToPoint(points[2], points[7]);
context.AddLineToPoint(points[0], points[7]);
context.ClosePath();
context.DrawPath(CGPathDrawingMode.FillStroke);
// Light
UIColor.White.ColorWithAlpha(0.2f).SetFill();
float mid = (float)Math.Round(size.Height / 2) + 0.5f;
context.MoveTo(0.5f, radiusp);
context.AddArcToPoint(0.5f, 0.5f, radiusp, 0.5f, radius);
context.AddLineToPoint(wid2, 0.5f);
context.AddArcToPoint(wid1, 0.5f, wid1, radiusp, radius);
context.AddLineToPoint(wid1, mid);
context.AddLineToPoint(0.5f, mid);
context.ClosePath();
context.DrawPath(CGPathDrawingMode.FillStroke);
// pop context
UIGraphics.PopContext();
// get a UIImage from the image context
UIImage outputImage = new UIImage(UIGraphics.GetImageFromCurrentImageContext().CGImage, scale, UIImageOrientation.Up);
//write (debug)
//[UIImagePNGRepresentation(outputImage) writeToFile:@"/Users/mathieu/Desktop/test.png" atomically:YES];
// clean up drawing environment
UIGraphics.EndImageContext();
return outputImage;
}
示例8: PaintBackground
void PaintBackground(UIColor color)
{
UIBezierPath rectPath = UIBezierPath.FromRect (this.Bounds);
color.SetFill ();
rectPath.Fill ();
}