private static void SetLegalText(TTTAttributedLabel label) { var template = "SignupLegal".Tr(); var arg0 = "SignupToS".Tr(); var arg1 = "SignupPrivacy".Tr(); var arg0idx = String.Format(template, "{0}", arg1).IndexOf("{0}", StringComparison.Ordinal); var arg1idx = String.Format(template, arg0, "{1}").IndexOf("{1}", StringComparison.Ordinal); label.Text = (NSString)String.Format(template, arg0, arg1); label.AddLinkToURL( new NSUrl(Phoebe.Build.TermsOfServiceUrl.ToString()), new NSRange(arg0idx, arg0.Length)); label.AddLinkToURL( new NSUrl(Phoebe.Build.PrivacyPolicyUrl.ToString()), new NSRange(arg1idx, arg1.Length)); }
private void setupText(TTTAttributedLabel attributedLabel, CustomLinkLabel label) { if ((attributedLabel != null) && (label != null)) { NSMutableParagraphStyle paragraphStyle = new NSMutableParagraphStyle(); paragraphStyle.LineBreakMode = UILineBreakMode.WordWrap; if (label.LineSpacing > 0) { paragraphStyle.LineHeightMultiple = (float)label.LineSpacing; } UIElementsHelper.SetCustomLabelParagraphStyle(paragraphStyle, label); string text = string.Empty; if (!string.IsNullOrEmpty(label.Text)) { text = label.Text; } var attString = new NSMutableAttributedString(text, new UIStringAttributes { ForegroundColor = label.TextColor.ToUIColor(), Font = UIFont.SystemFontOfSize((nfloat)label.FontSize), ParagraphStyle = paragraphStyle, KerningAdjustment = null }); attributedLabel.LineBreakMode = UILineBreakMode.WordWrap; attributedLabel.Lines = 0; attributedLabel.TextAlignment = paragraphStyle.Alignment; if (!string.IsNullOrEmpty(label.UrlText) && !string.IsNullOrEmpty(label.Url) && !string.IsNullOrEmpty(label.Text) && label.Text.Contains(label.UrlText)) { attributedLabel.AddLinkToURL(new NSUrl(label.Url), new NSRange(label.Text.IndexOf(label.UrlText), label.UrlText.Length)); attributedLabel.Delegate = new LabelDelegate(); attString.AddAttribute(UIStringAttributeKey.ForegroundColor, label.LinkColor.ToUIColor(), new NSRange(label.Text.IndexOf(label.UrlText), label.UrlText.Length)); } attributedLabel.AttributedText = attString; } }
private static void SetLegalText (TTTAttributedLabel label) { var template = "SignupLegal".Tr (); var arg0 = "SignupToS".Tr (); var arg1 = "SignupPrivacy".Tr (); var arg0idx = String.Format (template, "{0}", arg1).IndexOf ("{0}", StringComparison.Ordinal); var arg1idx = String.Format (template, arg0, "{1}").IndexOf ("{1}", StringComparison.Ordinal); label.Text = (NSString)String.Format (template, arg0, arg1); label.AddLinkToURL ( new NSUrl (Phoebe.Build.TermsOfServiceUrl.ToString ()), new NSRange (arg0idx, arg0.Length)); label.AddLinkToURL ( new NSUrl (Phoebe.Build.PrivacyPolicyUrl.ToString ()), new NSRange (arg1idx, arg1.Length)); }