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


C# CGRect.Offset方法代码示例

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


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

示例1: Show

		/// <summary>
		/// Shows the action sheet picker from the view that was set as the owner.
		/// </summary>
		public void Show ()
		{
			// declare vars
			float titleBarHeight = 40;
			CGSize doneButtonSize = new CGSize (71, 30);
			CGSize actionSheetSize = new CGSize (owner.Frame.Width, DatePicker.Frame.Height + titleBarHeight);
			CGRect datePickerFrame = new CGRect (0, owner.Frame.Height - actionSheetSize.Height
				, actionSheetSize.Width, actionSheetSize.Height);

			// show the action sheet and add the controls to it
			//actionSheet.ShowInView (owner);
			owner.AddSubview (datePickerView);
			// Set the Y offset of the frame 100, so that it can be brought back upwards in a slide animation
			datePickerFrame.Offset (0, 100);
			// resize the date picker frame to fit our other stuff
			datePickerView.Frame = datePickerFrame;

			// move our picker to be at the bottom of the actionsheet (view coords are relative to the action sheet)
			DatePicker.Frame = new CGRect ((nfloat)DatePicker.Frame.X, titleBarHeight, DatePicker.Frame.Width, DatePicker.Frame.Height);

			// move our label to the top of the action sheet
			titleLabel.Frame = new CGRect (10, 4, owner.Frame.Width - 100, 35);

			// move our button
			doneButton.Frame = new CGRect (actionSheetSize.Width - doneButtonSize.Width - 10, 7, doneButtonSize.Width, doneButtonSize.Height);

			// First set the alpha of the datePickerView to 0 to prepare for a fade in animation
			datePickerView.Alpha = 0;
			// Store datePickerView.Frame in the temporary variable to allow it to be animated
			datePickerFrame = datePickerView.Frame;
			UIView.Animate (0.2, () => {
				datePickerFrame.Offset (0, -100);
				datePickerView.Frame = datePickerFrame;
				datePickerView.Alpha = 1;
			});
		}
开发者ID:ARMoir,项目名称:mobile-samples,代码行数:39,代码来源:UIViewDatePicker.cs

示例2: SCBoxNode

		public static SCNNode SCBoxNode (string title, CGRect frame, NSColor color, float cornerRadius, bool centered)
		{
			NSMutableDictionary titleAttributes = null;
			NSMutableDictionary centeredTitleAttributes = null;

			// create and extrude a bezier path to build the box
			var path = NSBezierPath.FromRoundedRect (frame, cornerRadius, cornerRadius);
			path.Flatness = 0.05f;

			var shape = SCNShape.Create (path, 20);
			shape.ChamferRadius = 0.0f;

			var node = SCNNode.Create ();
			node.Geometry = shape;

			// create an image and fill with the color and text
			var textureSize = new CGSize ();
			textureSize.Width = NMath.Ceiling (frame.Size.Width * 1.5f);
			textureSize.Height = NMath.Ceiling (frame.Size.Height * 1.5f);

			var texture = new NSImage (textureSize);
			texture.LockFocus ();

			var drawFrame = new CGRect (0, 0, textureSize.Width, textureSize.Height);

			nfloat hue, saturation, brightness, alpha;

			(color.UsingColorSpace (NSColorSpace.DeviceRGBColorSpace)).GetHsba (out hue, out saturation, out brightness, out alpha);
			var lightColor = NSColor.FromDeviceHsba (hue, saturation - 0.2f, brightness + 0.3f, alpha);
			lightColor.Set ();

			NSGraphics.RectFill (drawFrame);

			NSBezierPath fillpath = null;

			if (cornerRadius == 0 && centered == false) {
				//special case for the "labs" slide
				drawFrame.Offset (0, -2);
				fillpath = NSBezierPath.FromRoundedRect (drawFrame, cornerRadius, cornerRadius);
			} else {
				drawFrame.Inflate (-3, -3);
				fillpath = NSBezierPath.FromRoundedRect (drawFrame, cornerRadius, cornerRadius);
			}

			color.Set ();
			fillpath.Fill ();

			// draw the title if any
			if (title != null) {
				if (titleAttributes == null) {
					var paraphStyle = new NSMutableParagraphStyle ();
					paraphStyle.LineBreakMode = NSLineBreakMode.ByWordWrapping;
					paraphStyle.Alignment = NSTextAlignment.Center;
					paraphStyle.MinimumLineHeight = 38;
					paraphStyle.MaximumLineHeight = 38;

					var font = NSFont.FromFontName ("Myriad Set Semibold", 34) != null ? NSFont.FromFontName ("Myriad Set Semibold", 34) : NSFont.FromFontName ("Avenir Medium", 34);

					var shadow = new NSShadow ();
					shadow.ShadowOffset = new CGSize (0, -2);
					shadow.ShadowBlurRadius = 4;
					shadow.ShadowColor = NSColor.FromDeviceWhite (0.0f, 0.5f);

					titleAttributes = new NSMutableDictionary ();
					titleAttributes.SetValueForKey (font, NSAttributedString.FontAttributeName);
					titleAttributes.SetValueForKey (NSColor.White, NSAttributedString.ForegroundColorAttributeName);
					titleAttributes.SetValueForKey (shadow, NSAttributedString.ShadowAttributeName);
					titleAttributes.SetValueForKey (paraphStyle, NSAttributedString.ParagraphStyleAttributeName);

					var centeredParaphStyle = (NSMutableParagraphStyle)paraphStyle.MutableCopy ();
					centeredParaphStyle.Alignment = NSTextAlignment.Center;

					centeredTitleAttributes = new NSMutableDictionary ();
					centeredTitleAttributes.SetValueForKey (font, NSAttributedString.FontAttributeName);
					centeredTitleAttributes.SetValueForKey (NSColor.White, NSAttributedString.ForegroundColorAttributeName);
					centeredTitleAttributes.SetValueForKey (shadow, NSAttributedString.ShadowAttributeName);
					centeredTitleAttributes.SetValueForKey (paraphStyle, NSAttributedString.ParagraphStyleAttributeName);
				}

				var attrString = new NSAttributedString (title, centered ? centeredTitleAttributes : titleAttributes);
				var textSize = attrString.Size;

				//check if we need two lines to draw the text
				var twoLines = title.Contains ("\n");
				if (!twoLines)
					twoLines = textSize.Width > frame.Size.Width && title.Contains (" ");

				//if so, we need to adjust the size to center vertically
				if (twoLines)
					textSize.Height += 38;

				if (!centered)
					drawFrame.Inflate (-15, 0);

				//center vertically
				var dy = (drawFrame.Size.Height - textSize.Height) * 0.5f;
				var drawFrameHeight = drawFrame.Size.Height;
				drawFrame.Size = new CGSize (drawFrame.Size.Width, drawFrame.Size.Height - dy);
				attrString.DrawString (drawFrame);
			}
//.........这里部分代码省略.........
开发者ID:shriharipathak,项目名称:mac-samples,代码行数:101,代码来源:Utils.cs

示例3: MMButtonRectMake

		//#pragma mark - Layout.

	public CGRect MMButtonRectMake(CGRect rect, CGRect contentRect, UIUserInterfaceIdiom interfaceIdiom){
		rect.Offset( contentRect.X, contentRect.Y);

		if (interfaceIdiom == UIUserInterfaceIdiom.Pad) {
		nfloat inset = MMNumberKeyboardPadSpacing / 2.0f;
		rect = rect.Inset( inset, inset);
		}

		return rect;
	}
开发者ID:XamarinControls,项目名称:matmartinez-MMNumberKeyboard,代码行数:12,代码来源:MMNumberKeyboard.cs

示例4: RenderPage

		/*
		 * Render the page here: we assume we are already in a normalized coordinate system which maps
		 * 	our standard aspect ratio (3:4) to (1:1)
		 * The reason why we do this is to reuse the same drawing code for both the preview and the
		 * 	full screen; for full screen rendering, we map the whole view, whereas the preview maps
		 * 	the whole preview image to a quarter of the page.
		 * */
		public CGRect [] RenderPage (Page page, CGSize size, bool unstyledDrawing)
		{
			var pageRect = new CGRect (0, 0, size.Width, size.Height);
			var paragraphBounds = new CGRect [page.Paragraphs.Count];

			using (var ctxt = UIGraphics.GetCurrentContext ()) {
				// fill background
				ctxt.SetFillColor (UIColor.FromHSBA (0.11f, 0.2f, 1, 1).CGColor);
				ctxt.FillRect (pageRect);

				pageRect = pageRect.Inset (20, 20);

				int i = 0;
				foreach (var p in page.Paragraphs) {
					var bounds = new CGRect (pageRect.X, pageRect.Y, 0, 0);

					if (UnstyledDrawing) {

						var text = new NSString (page.StringForParagraph (p));

						var font = UIFont.FromName ("HoeflerText-Regular", 24);

						// draw text with the old legacy path, setting the font color to black.
						ctxt.SetFillColor (UIColor.Black.CGColor);
						bounds.Size = text.DrawString (pageRect, font);

					} else {

						// TODO: draw attributed text with new string drawing
						var text = page.AttributedStringForParagraph (p);
						var textContext = new NSStringDrawingContext ();

						text.DrawString (pageRect, NSStringDrawingOptions.UsesLineFragmentOrigin, textContext);

						bounds = textContext.TotalBounds;
						bounds.Offset (pageRect.X, pageRect.Y);
					}

					paragraphBounds [i++] = bounds;

					pageRect.Y += bounds.Height;
				}

				return paragraphBounds;
			}
		}
开发者ID:CBrauer,项目名称:monotouch-samples,代码行数:53,代码来源:PageView.cs


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