public static CATextLayer RenderLabel(Mapsui.Geometries.Point point, LabelStyle style, IFeature feature, IViewport viewport, string text) { // Offset stackOffset, Mapsui.Geometries.Point p = viewport.WorldToScreen(point); //var pointF = new xPointF((float)p.X, (float)p.Y); var label = new CATextLayer (); var aString = new Foundation.NSAttributedString (text, new CoreText.CTStringAttributes(){ Font = new CoreText.CTFont("ArialMT", 10) }); var frame = new CGRect(new CoreGraphics.CGPoint((int)p.X, (int)p.Y), GetSizeForText(0, aString)); //label.Frame = frame; //frame.Width = (float)(p2.X - p1.X);// + margin); //frame.Height = (float)(p1.Y - p2.Y); label.FontSize = 10; label.ForegroundColor = new CoreGraphics.CGColor (0, 0, 255, 150); label.BackgroundColor = new CoreGraphics.CGColor (255, 0, 2, 150); label.String = text; label.Frame = frame; Console.WriteLine ("Pos " + label.Frame.X + ":" + label.Frame.Y + " w " + label.Frame.Width + " h " + label.Frame.Height); // = MonoTouch.UIKit.UIScreen.MainScreen.Scale; // label.ContentsScale = scale; return label; }
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); }
public static CATextLayer RenderLabel(Mapsui.Geometries.Point point, LabelStyle style, IFeature feature, IViewport viewport, string text) { // Offset stackOffset, Mapsui.Geometries.Point p = viewport.WorldToScreen(point); //var pointF = new xPointF((float)p.X, (float)p.Y); var label = new CATextLayer(); var aString = new Foundation.NSAttributedString(text, new CoreText.CTStringAttributes() { Font = new CoreText.CTFont("ArialMT", 10) }); var frame = new CGRect(new CoreGraphics.CGPoint((int)p.X, (int)p.Y), GetSizeForText(0, aString)); //label.Frame = frame; //frame.Width = (float)(p2.X - p1.X);// + margin); //frame.Height = (float)(p1.Y - p2.Y); label.FontSize = 10; label.ForegroundColor = new CoreGraphics.CGColor(0, 0, 255, 150); label.BackgroundColor = new CoreGraphics.CGColor(255, 0, 2, 150); label.String = text; label.Frame = frame; Console.WriteLine("Pos " + label.Frame.X + ":" + label.Frame.Y + " w " + label.Frame.Width + " h " + label.Frame.Height); // = MonoTouch.UIKit.UIScreen.MainScreen.Scale; // label.ContentsScale = scale; return(label); }
private static CGSize GetSizeForText(int width, Foundation.NSAttributedString aString) { var frameSetter = new CoreText.CTFramesetter(aString); Foundation.NSRange range; var size = (CGSize)frameSetter.SuggestFrameSize((NSRange) new Foundation.NSRange(0, 0), (CTFrameAttributes)null, (CGSize) new CoreGraphics.CGSize(width, Int32.MaxValue), out range); return(size); }
private static CGSize GetSizeForText(int width, Foundation.NSAttributedString aString) { var frameSetter = new CoreText.CTFramesetter(aString); Foundation.NSRange range; //CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString( (CFMutableAttributedStringRef) attributedString); var size = (CGSize)frameSetter.SuggestFrameSize((NSRange) new Foundation.NSRange(0, 0), (CTFrameAttributes)null, (CGSize) new CoreGraphics.CGSize(width, Int32.MaxValue), out range); //CGSize suggestedSize = CTFramesetterSuggestFrameSizeWithConstraints(framesetter, CFRangeMake(0, 0), NULL, CGSizeMake(inWidth, CGFLOAT_MAX), NULL); //CFRelease(framesetter); Console.WriteLine("Size = " + size.Width + ":" + size.Height + "Range = " + range.Length); return(size); }
public void Append(NSAttributedString first, params object [] rest) { Append(first); foreach (var obj in rest) { if (obj is NSAttributedString) { Append((NSAttributedString)obj); } else if (obj is string) { Append(new NSAttributedString((string)obj)); } else { Append(new NSAttributedString(obj.ToString())); } } }
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; }
public virtual void AppendAttributedString(NSAttributedString attributedString) { }
public virtual void SetAttributedString(NSAttributedString attributedString) { }
public virtual void ReplaceCharactersInRange(NSRange aRange, NSAttributedString withAttributedString) { }
public virtual void InsertAttributedString(NSAttributedString attributedString, int atIndex) { }
public NSAttributedString(NSAttributedString attributedString) { }
public virtual bool IsEqualToAttributedString(NSAttributedString otherString) { return(default(bool)); }