当前位置: 首页>>代码示例>>C#>>正文


C# CGContext.SetFillColorWithColor方法代码示例

本文整理汇总了C#中CGContext.SetFillColorWithColor方法的典型用法代码示例。如果您正苦于以下问题:C# CGContext.SetFillColorWithColor方法的具体用法?C# CGContext.SetFillColorWithColor怎么用?C# CGContext.SetFillColorWithColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CGContext的用法示例。


在下文中一共展示了CGContext.SetFillColorWithColor方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DrawInContext

    public override void DrawInContext(CGContext context)
    {
        // Start with a background whose color we don't use in the demo
        context.SetGrayFillColor (0.2f, 1);
        context.FillRect (Bounds);

        // We want to just lay down the background without any blending so we use the Copy mode rather than Normal
        context.SetBlendMode(CGBlendMode.Copy);

        // Draw a rect with the "background" color - this is the "Destination" for the blending formulas
        context.SetFillColorWithColor (DestinationColor.CGColor);
        context.FillRect(new RectangleF (110, 20, 100, 100));

        // Set up our blend mode
        context.SetBlendMode (BlendMode);

        // And draw a rect with the "foreground" color - this is the "Source" for the blending formulas
        context.SetFillColorWithColor (SourceColor.CGColor);
        context.FillRect (new RectangleF (60, 45, 200, 50));
    }
开发者ID:CVertex,项目名称:monotouch-samples,代码行数:20,代码来源:blend.cs

示例2: DrawElementView

		public void DrawElementView(RectangleF rect, CGContext context, UITableViewElementCell cell)
		{
			var gradientFrame = rect;
			
			var shineFrame = gradientFrame;
			shineFrame.Y += 1;
			shineFrame.X += 1;
			shineFrame.Width -= 2;
			shineFrame.Height = (shineFrame.Height / 2);

			CGColorSpace colorSpace = CGColorSpace.CreateDeviceRGB();

			var gradient = new CGGradient(
			    colorSpace,
			    new float[] { 0f, 0f,0f, 0.70f, 
							  0f, 0f, 0f, 0.40f},
				new float[] { 0, 1 } );

			var shineGradient = new CGGradient(
			    colorSpace,
			    new float[] { 1f, 1f, 1f, 0.80f, 
							  1f, 1f, 1f, 0.10f},
				new float[] { 0, 1 } );
			
			if (Cell != null && Cell.Highlighted)
			{
				context.SetFillColorWithColor(HighlightColor.CGColor);
			}
			else
			{
				context.SetFillColorWithColor(CellBackgroundColor.CGColor);
			}
			context.FillRect(rect);
	
			context.DrawLinearGradient(gradient, new PointF(gradientFrame.Left, gradientFrame.Top), new PointF(gradientFrame.Left, gradientFrame.Bottom), CGGradientDrawingOptions.DrawsAfterEndLocation);		
			context.DrawLinearGradient(shineGradient, new PointF(shineFrame.Left, shineFrame.Top), new PointF(shineFrame.Left, shineFrame.Bottom), CGGradientDrawingOptions.DrawsAfterEndLocation);
		}
开发者ID:vknair74,项目名称:MonoMobile.Views,代码行数:37,代码来源:GlassButtonTheme.cs

示例3: DrawContentView

		public void DrawContentView(RectangleF rect, CGContext context, UITableViewElementCell cell)
		{
			context.SaveState();
			
			var backgroundColor = CellBackgroundColor;
			if (backgroundColor != null)
			{
				if (backgroundColor == UIColor.Clear)
					backgroundColor = UIColor.White;
				
				context.SetFillColorWithColor(backgroundColor.ColorWithAlpha(0.4f).CGColor);
				context.SetBlendMode(CGBlendMode.Overlay);
				context.FillRect(rect);
			}
			
			context.RestoreState();
		}
开发者ID:CartBlanche,项目名称:MonoMobile.MVVM,代码行数:17,代码来源:SampleTheme.cs

示例4: 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);
    }
开发者ID:CVertex,项目名称:monotouch-samples,代码行数:35,代码来源:rendereddrawing.cs

示例5: FillRoundedRect

		void FillRoundedRect (RectangleF rect, CGContext context)
		{
			float radius = 10.0f;
			context.BeginPath ();
			//context.SetGrayFillColor (0.0f, this.Opacity);
			context.MoveTo (rect.GetMinX () + radius, rect.GetMinY ());
			context.AddArc (rect.GetMaxX () - radius, rect.GetMinY () + radius, radius, (float)(3 * Math.PI / 2), 0f, false);
			context.AddArc (rect.GetMaxX () - radius, rect.GetMaxY () - radius, radius, 0, (float)(Math.PI / 2), false);
			context.AddArc (rect.GetMinX () + radius, rect.GetMaxY () - radius, radius, (float)(Math.PI / 2), (float)Math.PI, false);
			context.AddArc (rect.GetMinX () + radius, rect.GetMinY () + radius, radius, (float)Math.PI, (float)(3 * Math.PI / 2), false);
			context.ClosePath ();
			context.SetFillColorWithColor(this.RectangleColor.CGColor);		
			context.FillPath ();
			
			context.SetStrokeColorWithColor(RectangleBorderColor.CGColor);	
			context.BeginPath ();
			//context.SetGrayFillColor (0.0f, this.Opacity);
			context.MoveTo (rect.GetMinX () + radius, rect.GetMinY ());
			context.AddArc (rect.GetMaxX () - radius, rect.GetMinY () + radius, radius, (float)(3 * Math.PI / 2), 0f, false);
			context.AddArc (rect.GetMaxX () - radius, rect.GetMaxY () - radius, radius, 0, (float)(Math.PI / 2), false);
			context.AddArc (rect.GetMinX () + radius, rect.GetMaxY () - radius, radius, (float)(Math.PI / 2), (float)Math.PI, false);
			context.AddArc (rect.GetMinX () + radius, rect.GetMinY () + radius, radius, (float)Math.PI, (float)(3 * Math.PI / 2), false);
			context.ClosePath ();
			
			context.StrokePath();
		}
开发者ID:nagyist,项目名称:InstantDatabase,代码行数:26,代码来源:MBProgressHUD.cs


注:本文中的CGContext.SetFillColorWithColor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。