예제 #1
0
        private static CATextLayer CreateCATextLayer(LabelStyle style, string text)
        {
            var label = new CATextLayer();

            var ctFont  = new CoreText.CTFont(style.Font.FontFamily, (float)style.Font.Size);
            var aString = new Foundation.NSAttributedString(text,
                                                            new CoreText.CTStringAttributes()
            {
                Font = ctFont
            });

            label.SetFont(ctFont);
            label.FontSize        = (float)style.Font.Size;
            label.ForegroundColor = ToCGColor(style.ForeColor);
            label.BackgroundColor = TransparentColor;
            label.ShadowOpacity   = 0;
            label.BorderWidth     = 0;

            label.String = text;

            var size = GetSizeForText(0, aString);

            label.Frame = new CGRect(0, 0, size.Width, size.Height);

            return(label);
        }
예제 #2
0
		private static CATextLayer CreateCATextLayer(LabelStyle style, string text)
		{
			var label = new CATextLayer ();

			var ctFont = new CoreText.CTFont (style.Font.FontFamily, (float)style.Font.Size);
			var aString = new Foundation.NSAttributedString (text, 
				new CoreText.CTStringAttributes() { Font = ctFont });

			label.SetFont(ctFont);
			label.FontSize = (float)style.Font.Size;
			label.ForegroundColor = ToCGColor(style.ForeColor);
			label.BackgroundColor = TransparentColor;
			label.ShadowOpacity = 0;
			label.BorderWidth = 0;

			label.String = text;

			var size = GetSizeForText (0, aString);

			label.Frame = new CGRect (0, 0, size.Width, size.Height);

			return label;
		}