當前位置: 首頁>>代碼示例>>C#>>正文


C# UIColor.SetColor方法代碼示例

本文整理匯總了C#中UIKit.UIColor.SetColor方法的典型用法代碼示例。如果您正苦於以下問題:C# UIColor.SetColor方法的具體用法?C# UIColor.SetColor怎麽用?C# UIColor.SetColor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在UIKit.UIColor的用法示例。


在下文中一共展示了UIColor.SetColor方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: newImage

        public static UIImage newImage(CGRect rect,UIColor color)
        {
            using (var cs = CGColorSpace.CreateDeviceRGB ()){
                using (var context = new CGBitmapContext (IntPtr.Zero, (int)rect.Width, (int)rect.Height, 8, (int)rect.Height*4, cs, CGImageAlphaInfo.PremultipliedLast)){

                    rect.X += 5;
                    rect.Y += 5;
                    rect.Width -= 10;
                    rect.Height -= 10;

                    color.SetColor ();
                    context.MoveTo (rect.X,rect.Y);
                    context.AddLineToPoint (rect.X,rect.Height);
                    context.AddLineToPoint (rect.Width,rect.Height);
                    context.AddLineToPoint (rect.Width,rect.Y);
                    context.ClosePath ();
                    context.FillPath ();

                return UIImage.FromImage (context.ToImage());
                }
            }
        }
開發者ID:Clancey,項目名稱:UICalendar,代碼行數:22,代碼來源:Graphics.cs

示例2: Draw

		public override void Draw (CGRect rect)
		{
			var context = UIGraphics.GetCurrentContext ();

			MessageBarStyleSheet styleSheet = StylesheetProvider.StyleSheetForMessageView (this);
			context.SaveState ();

			styleSheet.BackgroundColorForMessageType (MessageType).SetColor ();
			context.FillRect (rect);
			context.RestoreState ();
			context.SaveState ();

            var color = styleSheet.StrokeColorForMessageType (MessageType);
			context.BeginPath ();
			context.MoveTo (0, rect.Size.Height);
			context.SetStrokeColor (color.CGColor);
			context.SetLineWidth (1);
			context.AddLineToPoint (rect.Size.Width, rect.Size.Height);
			context.StrokePath ();
			context.RestoreState ();
			context.SaveState ();

			nfloat xOffset = Padding;
			nfloat yOffset = Padding;

            var icon = styleSheet.IconImageForMessageType(MessageType);
            if (icon != null)
                icon.Draw(new CGRect (xOffset, yOffset, IconSize, IconSize));

			context.SaveState ();

			yOffset -= TextOffset;
            xOffset += (icon == null ? 0 : IconSize) + Padding;
			CGSize titleLabelSize = TitleSize ();
			if (string.IsNullOrEmpty (Title) && !string.IsNullOrEmpty (Description)) {
				yOffset = (float)(Math.Ceiling ((double)rect.Size.Height * 0.5) - Math.Ceiling ((double)titleLabelSize.Height * 0.5) - TextOffset);
			}
            TitleColor = color;
			TitleColor.SetColor ();

			var titleRectangle = new CGRect (xOffset, yOffset, titleLabelSize.Width, titleLabelSize.Height);
            Title.DrawString(titleRectangle, new UIStringAttributes { Font = TitleFont, ForegroundColor = TitleColor });
            yOffset += titleLabelSize.Height;

			CGSize descriptionLabelSize = DescriptionSize ();

            DescriptionColor = color;
            DescriptionColor.SetColor ();
			var descriptionRectangle = new CGRect (xOffset, yOffset, descriptionLabelSize.Width, descriptionLabelSize.Height);
            Description.DrawString(descriptionRectangle, new UIStringAttributes { Font = DescriptionFont, ForegroundColor = DescriptionColor });
		}
開發者ID:modulexcite,項目名稱:userdialogs,代碼行數:51,代碼來源:MessageView.cs


注:本文中的UIKit.UIColor.SetColor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。