Esempio n. 1
0
        internal UITextAttributes(NSDictionary dict)
        {
            if (dict == null)
                return;

            NSObject val;

            if (dict.TryGetValue (UITextAttributesConstants.Font, out val))
                Font = val as UIFont;
            if (dict.TryGetValue (UITextAttributesConstants.TextColor, out val))
                TextColor = val as UIColor;
            if (dict.TryGetValue (UITextAttributesConstants.TextShadowColor, out val))
                TextShadowColor = val as UIColor;
            if (dict.TryGetValue (UITextAttributesConstants.TextShadowOffset, out val)) {
                var value = val as NSValue;
                if (value != null)
                    TextShadowOffset = value.UIOffsetValue;
            }
        }
Esempio n. 2
0
 internal static NSDictionary ToDictionary(
     UIFont font,
     UIColor foregroundColor,
     UIColor backgroundColor,
     UIColor strokeColor,
     NSParagraphStyle paragraphStyle,
     NSLigatureType ligature,
     float kerning,
     NSUnderlineStyle underlineStyle,
     NSShadow shadow,
     float strokeWidth,
     NSUnderlineStyle strikethroughStyle)
 {
     var attr = new UIStringAttributes ();
     if (font != null){
         attr.Font = font;
     }
     if (foregroundColor != null){
         attr.ForegroundColor = foregroundColor;
     }
     if (backgroundColor != null){
         attr.BackgroundColor = backgroundColor;
     }
     if (strokeColor != null){
         attr.StrokeColor = strokeColor;
     }
     if (paragraphStyle != null){
         attr.ParagraphStyle = paragraphStyle;
     }
     if (ligature != NSLigatureType.Default){
         attr.Ligature = ligature;
     }
     if (kerning != 0){
         attr.KerningAdjustment = kerning;
     }
     if (underlineStyle != NSUnderlineStyle.None){
         attr.UnderlineStyle = underlineStyle;
     }
     if (shadow != null){
         attr.Shadow = shadow;
     }
     if (strokeWidth != 0){
         attr.StrokeWidth = strokeWidth;
     }
     if (strikethroughStyle != NSUnderlineStyle.None){
         attr.StrikethroughStyle = strikethroughStyle;
     }
     var dict = attr.Dictionary;
     return dict.Count == 0 ? null : dict;
 }
Esempio n. 3
0
 public NSAttributedString(string str,
     UIFont font = null,
     UIColor foregroundColor = null,
     UIColor backgroundColor = null,
     UIColor strokeColor = null,
     NSParagraphStyle paragraphStyle = null,
     NSLigatureType ligatures = NSLigatureType.Default,
     float kerning = 0,
     NSUnderlineStyle underlineStyle = NSUnderlineStyle.None,
     NSShadow shadow = null,
     float strokeWidth = 0,
     NSUnderlineStyle strikethroughStyle = NSUnderlineStyle.None)
     : this(str, ToDictionary (font, foregroundColor, backgroundColor, strokeColor, paragraphStyle, ligatures, kerning, underlineStyle, shadow, strokeWidth, strikethroughStyle))
 {
 }