本文整理汇总了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());
}
}
}
示例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 });
}