本文整理汇总了C#中NSString.StringSize方法的典型用法代码示例。如果您正苦于以下问题:C# NSString.StringSize方法的具体用法?C# NSString.StringSize怎么用?C# NSString.StringSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NSString
的用法示例。
在下文中一共展示了NSString.StringSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public override void Draw(RectangleF rect)
{
base.Draw (rect);
var ctx = UIGraphics.GetCurrentContext();
var center = new PointF(Bounds.X + Bounds.Width / 2.0f, Bounds.Y + Bounds.Height / 2.0f);
var maxRadius = distance(Bounds.Width, Bounds.Height) / 2.0f;
ctx.SetLineWidth(10);
CircleColor.SetStroke();
for (float currentRadius = maxRadius; currentRadius > 0; currentRadius -= 20.0f) {
ctx.AddArc(center.X, center.Y, currentRadius, 0.0f, (float)Math.PI * 2.0f, true);
ctx.StrokePath();
}
var text = new NSString("You are getting sleepy.");
var font = UIFont.BoldSystemFontOfSize(28.0f);
var textSize = text.StringSize(font);
UIColor.Black.SetFill();
var offset = new SizeF(4.0f, 3.0f);
ctx.SetShadowWithColor(offset, 2.0f, UIColor.DarkGray.CGColor);
text.DrawString(new PointF(center.X - textSize.Width / 2.0f, center.Y - textSize.Height / 2.0f), font);
}
示例2: HistoryBar
public HistoryBar( CGRect parentFrame, EventHandler onSettingsPressed )
: base()
{
Layer.AnchorPoint = CGPoint.Empty;
// setup the left label
NSString leftLabel = new NSString( "" );
SettingsButton = UIButton.FromType( UIButtonType.System );
SettingsButton.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( Settings.General_IconFont, 32 );
SettingsButton.SetTitle( leftLabel.ToString( ), UIControlState.Normal );
SettingsButton.SetTitleColor( Theme.GetColor( Config.Instance.VisualSettings.FooterTextColor ), UIControlState.Normal );
SettingsButton.TouchUpInside += onSettingsPressed;
CGSize labelSize = leftLabel.StringSize( SettingsButton.Font );
SettingsButton.Bounds = new CGRect( 0, 0, labelSize.Width, labelSize.Height );
// create the list that will store our items
HistoryList = new List<HistoryItem>();
// even tho there's nothing, update it so we have our label.
UpdateItems( );
TintColor = UIColor.Clear;
Translucent = false;
BarTintColor = Theme.GetColor( Config.Instance.VisualSettings.FooterBGColor );
Layer.Opacity = Settings.StatusBar_Opacity;
Bounds = new CGRect( 0, 0, parentFrame.Width, Settings.StatusBar_Height );
}
示例3: ContentSize
public static float ContentSize(string text, float width, UIFont font)
{
var stringToSize = new NSString (text);
var size = stringToSize.StringSize (font, new SizeF (width, float.MaxValue), UILineBreakMode.WordWrap);
return size.Height;
}
示例4: GetHeightForRow
public override float GetHeightForRow(UITableView tableView, NSIndexPath indexPath)
{
var content = data[indexPath.Row].Content;
var text = new NSString (content);
var size = text.StringSize (FontConstants.SourceSansProRegular (15), new SizeF (278, 70));
return size.Height + 40;
}
示例5: TextHeight
private float TextHeight(RectangleF bounds)
{
SizeF size;
using(NSString str = new NSString(this.Caption))
{
size = str.StringSize(_CaptionFont, new SizeF(bounds.Width - 20, 1000), UILineBreakMode.WordWrap);
}
return size.Height;
}
示例6: MonoStringHeight
public static float MonoStringHeight(this string s, UIFont font, float maxWidth)
{
if (string.IsNullOrEmpty(s))
return 0f;
using (var str = new NSString (s))
{
return str.StringSize(font, new SizeF(maxWidth, 1000), UILineBreakMode.WordWrap).Height;
}
}
示例7: MonoStringLength
public static float MonoStringLength(this string s, UIFont font)
{
if (string.IsNullOrEmpty(s))
return 0f;
using (var str = new NSString (s))
{
return str.StringSize(font).Width;
}
}
示例8: SetLabelHeight4Text
public static void SetLabelHeight4Text (this UILabel source, float width)
{
float height = 0f;
using (var nss = new NSString (source.Text)) {
height = nss.StringSize (source.Font, new SizeF (width, 1000.0f),
UILineBreakMode.WordWrap).Height;
}
source.Lines = 0;
source.Frame = new RectangleF (source.Frame.X, source.Frame.Y, width, height);
}
示例9: LayoutSubviews
public override void LayoutSubviews()
{
base.LayoutSubviews ();
var text = new NSString (VerseContent.Text);
var maxSize = new SizeF (278, 70);
var currentSize = text.StringSize (FontConstants.SourceSansProRegular (15), maxSize);
VerseReference.Frame = new RectangleF (22, 9, 278, 20);
VerseContent.Frame = new RectangleF (24, 30, 278, currentSize.Height);
}
示例10: GetHeight4Text
public static float GetHeight4Text (this UILabel source, float width)
{
if (string.IsNullOrEmpty (source.Text)) {
return 0;
}
using (var nss = new NSString(source.Text)) {
float height = nss.StringSize (source.Font, new SizeF (width, 1000.0f),
UILineBreakMode.WordWrap).Height;
return height;
}
}
示例11: Render
static UIImage Render (string value)
{
NSString text = new NSString (string.IsNullOrEmpty (value) ? " " : value);
UIFont font = UIFont.SystemFontOfSize (20);
SizeF size = text.StringSize (font);
UIGraphics.BeginImageContextWithOptions (size, false, 0.0f);
UIColor.Red.SetColor ();
text.DrawString (new PointF (0, 0), font);
UIImage image = UIGraphics.GetImageFromCurrentImageContext ();
UIGraphics.EndImageContext ();
return image;
}
示例12: Draw
public override void Draw (RectangleF rect)
{
base.Draw (rect);
var st = new NSString(Text);
var sz = st.StringSize (Font);
CGContext context = UIGraphics.GetCurrentContext();
context.SetFillColor (AppDelegate.ColorTextLink.CGColor);
context.SetLineWidth(0.5f);
context.MoveTo(0,sz.Height+2);
context.AddLineToPoint(sz.Width,sz.Height+2);
context.StrokePath();
}
示例13: GetCellHeight
public static float GetCellHeight(RectangleF bounds, Tweet tweet)
{
bounds.Height = 999;
// Keep the same as LayoutSubviews
bounds.X = 0;
bounds.Width -= 5;
using (var nss = new NSString (tweet.Text))
{
var dim = nss.StringSize (UIFont.SystemFontOfSize(15), bounds.Size, UILineBreakMode.WordWrap);
return Math.Max (dim.Height + 5 + + 14 + 2*4, 20);
}
}
示例14: GetCellHeight
public static float GetCellHeight (RectangleF bounds, string caption)
{
bounds.Height = 999;
// Keep the same as LayoutSubviews
bounds.X = TEXT_LEFT_START;
bounds.Width -= TEXT_LEFT_START + TEXT_HEIGHT_PADDING;
if (!string.IsNullOrEmpty (caption)) {
using (var nss = new NSString (caption)) {
var dim = nss.StringSize (TextFont, bounds.Size, UILineBreakMode.WordWrap);
return Math.Max (dim.Height + TEXE_YOFFSET + 2 * TEXT_HEIGHT_PADDING, MIN_HEIGHT);
}
}
return MIN_HEIGHT;
}
示例15: GetHeight
public override float GetHeight (UITableView tableView, NSIndexPath indexPath)
{
if (string.IsNullOrEmpty (Caption)) {
return 44.0f;
} else {
NSString s = new NSString (this.Caption);
float height = s.StringSize (
UIFont.SystemFontOfSize (12.0f),
new System.Drawing.SizeF (280.0f, 5000.0f),
UILineBreakMode.WordWrap
).Height;
return height;
}
}