예제 #1
0
        internal static NSAttributedString ToAttributed(this FormattedString formattedString, Element owner, Color defaultForegroundColor)
        {
            if (formattedString == null)
            {
                return((NSAttributedString)null);
            }
            NSMutableAttributedString attributedString = new NSMutableAttributedString();

            foreach (Span span in formattedString.Spans)
            {
                if (span.Text != null)
                {
                    attributedString.Append(FormattedStringExtensions.ToAttributed(span, owner, defaultForegroundColor));
                }
            }
            return((NSAttributedString)attributedString);
        }
예제 #2
0
        private void UpdateText()
        {
            this.perfectSizeValid = false;

            object[] values = this.Element.GetValues(Label.FormattedTextProperty, Label.TextProperty, Label.TextColorProperty);

            FormattedString formattedString = (FormattedString)values [0];

            if (formattedString != null)
            {
                this.Control.AttributedStringValue = FormattedStringExtensions.ToAttributed(formattedString, (Element)this.Element, (Color)values [2]);
            }
            else
            {
                this.Control.StringValue = (string)values [1];
                this.Control.Font        = FontExtensions.ToUIFont(this.Element);
                this.Control.TextColor   = ColorExtensions.ToUIColor((Color)values [2], ColorExtensions.Black);
            }
            this.Layout();
        }