当前位置: 首页>>代码示例>>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;未经允许,请勿转载。