本文整理汇总了C#中CGContext.SetStrokeColorSpace方法的典型用法代码示例。如果您正苦于以下问题:C# CGContext.SetStrokeColorSpace方法的具体用法?C# CGContext.SetStrokeColorSpace怎么用?C# CGContext.SetStrokeColorSpace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGContext
的用法示例。
在下文中一共展示了CGContext.SetStrokeColorSpace方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawInContext
public override void DrawInContext(CGContext context)
{
// Draw the colored pattern. Since we have a CGColorRef for this pattern, we just set
// that color current and draw.
context.SetFillColorWithColor(coloredPatternColor);
context.FillRect(new RectangleF(10, 10, 90, 90));
// You can also stroke with a pattern.
context.SetStrokeColorWithColor(coloredPatternColor);
context.StrokeRectWithWidth(new RectangleF(120, 10, 90, 90), 8);
// Since we aren't encapsulating our pattern in a CGColor for the uncolored pattern case, setup requires two steps.
// First you have to set the context's current colorspace (fill or stroke) to a pattern colorspace,
// indicating to Quartz that you want to draw a pattern.
context.SetFillColorSpace(uncoloredPatternColorSpace);
// Next you set the pattern and the color that you want the pattern to draw with.
var color1 = new float [] {1, 0, 0, 1};
context.SetFillPattern(uncoloredPattern, color1);
// And finally you draw!
context.FillRect(new RectangleF(10, 120, 90, 90));
// As long as the current colorspace is a pattern colorspace, you are free to change the pattern or pattern color
var color2 = new float [] {0, 1, 0, 1};
context.SetFillPattern(uncoloredPattern, color2);
context.FillRect(new RectangleF(10, 230, 90, 90));
// And of course, just like the colored case, you can stroke with a pattern as well.
context.SetStrokeColorSpace(uncoloredPatternColorSpace);
context.SetStrokePattern(uncoloredPattern, color1);
context.StrokeRectWithWidth(new RectangleF(120, 120, 90, 90), 8);
// As long as the current colorspace is a pattern colorspace, you are free to change the pattern or pattern color
context.SetStrokePattern(uncoloredPattern, color2);
context.StrokeRectWithWidth(new RectangleF(120, 230, 90, 90), 8);
}