当前位置: 首页>>代码示例>>C#>>正文


C# NSString.StringSize方法代码示例

本文整理汇总了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);
        }
开发者ID:paulcbetts,项目名称:BigNerdIOS-MonoDevelop,代码行数:28,代码来源:HypnosisView.cs

示例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 );
        }
开发者ID:SparkDevNetwork,项目名称:FamilyManager,代码行数:31,代码来源:HistoryBar.cs

示例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;
        }
开发者ID:pierceboggan,项目名称:Verses,代码行数:7,代码来源:InterfaceHelper.cs

示例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;
        }
开发者ID:pierceboggan,项目名称:Verses,代码行数:8,代码来源:VersesTableSource.cs

示例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;
		}
开发者ID:briandonahue,项目名称:MonoTouch.MVVM,代码行数:9,代码来源:MovieElement.cs

示例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;
            }
        }
开发者ID:GSerjo,项目名称:appreciateui,代码行数:10,代码来源:StringExtensions.cs

示例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;
            }
        }
开发者ID:GSerjo,项目名称:appreciateui,代码行数:10,代码来源:StringExtensions.cs

示例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);
		}
开发者ID:bpug,项目名称:LbkIos,代码行数:11,代码来源:UILabelExtensions.cs

示例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);
        }
开发者ID:pierceboggan,项目名称:Verses,代码行数:11,代码来源:VerseCell.cs

示例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;
			}
			
		}
开发者ID:bpug,项目名称:LbkIos,代码行数:12,代码来源:UILabelExtensions.cs

示例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;
		}
开发者ID:GSerjo,项目名称:monotouch-samples,代码行数:13,代码来源:ImageProtocol.cs

示例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();  
		}
开发者ID:nicolaiarocci,项目名称:eve.mobile,代码行数:13,代码来源:UnderlineLabel.cs

示例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);
            }
        }
开发者ID:timrisi,项目名称:Hashed,代码行数:14,代码来源:TweetCell.cs

示例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;
		}
开发者ID:bpug,项目名称:LbkIos,代码行数:15,代码来源:VideoCell.cs

示例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;
				}
			}
开发者ID:Xipas,项目名称:Symplified.Auth,代码行数:16,代码来源:AppDelegate.cs


注:本文中的NSString.StringSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。