本文整理汇总了C#中CGPath.IsRect方法的典型用法代码示例。如果您正苦于以下问题:C# CGPath.IsRect方法的具体用法?C# CGPath.IsRect怎么用?C# CGPath.IsRect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGPath
的用法示例。
在下文中一共展示了CGPath.IsRect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public override void Draw (RectangleF rect)
{
Console.WriteLine ("# Draw: rect={{X={0}, Y={1}, Width={2}, Height={3}}}", rect.X, rect.Y, rect.Width, rect.Height);
// Initialize a graphics context and set the text matrix to a known value
var context = UIGraphics.GetCurrentContext ();
// context.TextMatrix = CGAffineTransform.MakeIdentity ();
context.TextMatrix = CGAffineTransform.MakeScale (1f, -1f);
// initialize a rectangular path
var path = new CGPath ();
// path.AddRect (new RectangleF (10.0f, 10.0f, 200.0f, 30.0f));
path.AddRect (rect);
RectangleF r;
Console.WriteLine ("path.IsRect={0}; Width={1}, Height={2}", path.IsRect (out r), r.Width, r.Height);
// initialize an attributed string
var attrString = new NSMutableAttributedString ("We hold this truth to be self evident, that everyone is created equal.");
// use a red font for the first 50 chars
attrString.AddAttributes(new CTStringAttributes () {
ForegroundColor = new CGColor (
CGColorSpace.CreateDeviceRGB(),
new[]{1.0f, 0.0f, 0.0f, 0.8f}
),
}, new NSRange (0, 50));
// Create the framesetter with the attributed string
using (var framesetter = new CTFramesetter (attrString)) {
NSRange fitRange;
var size = framesetter.SuggestFrameSize (new NSRange (), null, new SizeF (200f, 200f), out fitRange);
Console.WriteLine ("fitRange.Location={0}; fitRange.Length={1}", fitRange.Location, fitRange.Length);
Console.WriteLine ("Size: Width={0}; Height={1}", size.Width, size.Height);
// Create the frame and draw it into the graphics context
using (var frame = framesetter.GetFrame (new NSRange (0, 70), path, null))
frame.Draw (context);
context.ShowText ("hello, world!");
}
}