public static UIFont GetFontWithTraits(this UIFontDescriptorSymbolicTraits traits, nfloat size) { var desc = new UIFontDescriptor(); desc = desc.CreateWithTraits(traits); return(UIFont.FromDescriptor(desc, size)); }
private void UpdateFont() { var hasBold = Element.FontAttributes.HasFlag(FontAttributes.Bold); var hasItalic = Element.FontAttributes.HasFlag(FontAttributes.Italic); if (hasBold || hasItalic) { var withFamily = new UIFontDescriptor().CreateWithFamily(Element.FontFamily); var symbolicTraits = UIFontDescriptorSymbolicTraits.ClassUnknown; if (hasBold) { symbolicTraits |= UIFontDescriptorSymbolicTraits.Bold; } if (hasItalic) { symbolicTraits |= UIFontDescriptorSymbolicTraits.Italic; } Control.Font = UIFont.FromDescriptor(withFamily.CreateWithTraits(symbolicTraits), (nfloat)Element.FontSize); return; } //Font without any Bold/Italic attribute. Control.Font = UIFont.FromName(Element.FontFamily, (float)Element.FontSize); }
public static UIFont GetPreferredFont(NSString textStyle, float scale) { UIFontDescriptor tmp = UIFontDescriptor.GetPreferredDescriptorForTextStyle(textStyle); UIFontDescriptor newBaseDescriptor = tmp.CreateWithSize(tmp.PointSize * scale); return(UIFont.FromDescriptor(newBaseDescriptor, newBaseDescriptor.PointSize)); }
UIFont MakeFont(string name, float fsize, UIFontDescriptorSymbolicTraits traits) { var desc = UIFontDescriptor.FromName(name, fsize); desc = desc.CreateWithTraits(traits); return(UIFont.FromDescriptor(desc, fsize)); }
internal static bool IsBold(UIFont font) { UIFontDescriptor fontDescriptor = font.FontDescriptor; UIFontDescriptorSymbolicTraits traits = fontDescriptor.SymbolicTraits; return(traits.HasFlag(UIFontDescriptorSymbolicTraits.Bold)); }
/// <summary> /// Applies a font style to the current font. /// </summary> /// <param name="font">A font.</param> /// <param name="fontStyle">The font style.</param> /// <returns>A new font with the specified style applied.</returns> public static UIFont ApplyStyle(this UIFont font, FontStyle fontStyle) { if (fontStyle == FontStyle.None) { return(font); } UIFontDescriptorSymbolicTraits traits = UIFontDescriptorSymbolicTraits.ClassUnknown; if ((fontStyle & FontStyle.Bold) == FontStyle.Bold) { traits = UIFontDescriptorSymbolicTraits.Bold; } if ((fontStyle & FontStyle.Italic) == FontStyle.Italic) { traits |= UIFontDescriptorSymbolicTraits.Italic; } UIFontDescriptor fontDescriptor = font.FontDescriptor.CreateWithTraits(traits); if (fontDescriptor == null) { throw new ArgumentException("The font style (" + fontStyle + ") is not supported for font (" + font.Name + ").", nameof(fontStyle)); } return(UIFont.FromDescriptor(fontDescriptor, 0)); }
public override void PreferredContentSizeChanged() { labelView.Font = UIFont.GetPreferredFontForTextStyle(labelView.Font.FontDescriptor.FontAttributes.TextStyle); shortDescriptionTextView.Font = UIFont.GetPreferredFontForTextStyle(shortDescriptionTextView.Font.FontDescriptor.FontAttributes.TextStyle); descriptionTextView.Font = UIFont.GetPreferredFontForTextStyle(descriptionTextView.Font.FontDescriptor.FontAttributes.TextStyle); UIFontDescriptor descriptor = descriptionTextView.Font.FontDescriptor; descriptionTextView.Font = UIFont.GetPreferredFontForTextStyle(descriptor.FontAttributes.TextStyle); }
internal static UIFont Bold(this UIFont font) { UIFontDescriptor fontDescriptor = font.FontDescriptor; UIFontDescriptorSymbolicTraits traits = fontDescriptor.SymbolicTraits; traits = traits | UIFontDescriptorSymbolicTraits.Bold; UIFontDescriptor boldFontDescriptor = fontDescriptor.CreateWithTraits(traits); return(UIFont.FromDescriptor(boldFontDescriptor, font.PointSize)); }
internal static UIFont WithTraitsOfFont(this UIFont self, UIFont font) { UIFontDescriptor fontDescriptor = self.FontDescriptor; UIFontDescriptorSymbolicTraits traits = fontDescriptor.SymbolicTraits; traits = traits | font.FontDescriptor.SymbolicTraits; UIFontDescriptor boldFontDescriptor = fontDescriptor.CreateWithTraits(traits); return(UIFont.FromDescriptor(boldFontDescriptor, self.PointSize)); }
void UpdateFont() { ControlFont = Element.ToUIFont(); InvokeOnMainThread(() => { if (Control != null) { Control.Font = ControlFont; } }); ControlFontPointSize = Control.Font.PointSize; FontDescriptor = ControlFont.FontDescriptor; }
RootElement MakeFonts () { Console.WriteLine ("Changing"); // The baseline to show various adjustments you can make to a font baseline = UIFontDescriptor.PreferredBody; return new RootElement ("Fonts") { new Section () { new RootElement ("System Preferred Fonts"){ new Section () { new StyledStringElement ("Headline") { Font = UIFont.PreferredHeadline }, new StyledStringElement ("Subheadline") { Font = UIFont.PreferredSubheadline }, new StyledStringElement ("Body") { Font = UIFont.PreferredBody }, new StyledStringElement ("Caption1") { Font = UIFont.PreferredCaption1 }, new StyledStringElement ("Caption2") { Font = UIFont.PreferredCaption2 }, new StyledStringElement ("Footnote") { Font = UIFont.PreferredFootnote }, } }, new RootElement ("Font weight"){ new Section (){ MakeSample ("Body Plain", 0), MakeSample ("Body Bold", UIFontDescriptorSymbolicTraits.Bold), MakeSample ("Body Italic", UIFontDescriptorSymbolicTraits.Italic), } }, new RootElement ("Line Spacing") { new Section (){ MakeMultilineSample ("Line Spacing; regular; " + lorem, 0), MakeMultilineSample ("Line Spacing: tight; " + lorem, UIFontDescriptorSymbolicTraits.TightLeading), MakeMultilineSample ("Line Spacing: loose; " + lorem, UIFontDescriptorSymbolicTraits.LooseLeading), } }, new RootElement ("CoreText Font Features"){ new Section ("Use Proportional Number") { new StyledStringElement ("10:20") { Font = Resize (UIFont.PreferredBody) }, new StyledStringElement ("10:20") { Font = ResizeProportional (UIFont.PreferredBody) }, }, new Section ("Use Character Alternatives") { new StyledStringElement ("10:20") { Font = Resize (UIFont.PreferredBody) }, new StyledStringElement ("10:20") { Font = ResizeAlternative (UIFont.PreferredBody) }, }, new Section ("Use Proportional + Alternative") { new StyledStringElement ("10:20") { Font = Resize (UIFont.PreferredBody) }, new StyledStringElement ("10:20") { Font = ResizeProportionalAndAlternative (UIFont.PreferredBody) }, }, } }, }; }
protected override void OnElementChanged(ElementChangedEventArgs <Editor> e) { base.OnElementChanged(e); if (Control != null) { var editor = e.NewElement as ExtendedEditor; if (editor != null) { var Uifont = UIFontDescriptor.FromName(editor.FontFamily, (float)editor.FontSize); Control.Font = UIFont.FromDescriptor(Uifont, (float)editor.FontSize); Control.AutocapitalizationType = UITextAutocapitalizationType.Sentences; } } }
private UIFont FindFont(string fontFamily, float fontSize) { if (fontFamily != null) { try { if (UIFont.FamilyNames.Contains(fontFamily)) { var descriptor = new UIFontDescriptor().CreateWithFamily(fontFamily); return(UIFont.FromDescriptor(descriptor, fontSize)); } return(UIFont.FromName(fontFamily, fontSize)); } catch { } } return(UIFont.SystemFontOfSize(fontSize)); }
private PlatformFont GetFont() { if (_native == null) { #if __MACOS__ using (var descriptor = !string.IsNullOrEmpty(FontFamily) ? NSFontDescriptor.FromNameSize(FontFamily, FontSize) : new NSFontDescriptor()) { if (IsItalic) { using (var descriptor2 = descriptor.FontDescriptorWithSymbolicTraits(NSFontSymbolicTraits.ItalicTrait)) { _native = NSFont.FromDescription(descriptor2, FontSize); } } else { _native = NSFont.FromDescription(descriptor, FontSize); } } #else using (var descriptor = !string.IsNullOrEmpty(FontFamily) ? UIFontDescriptor.FromName(FontFamily, FontSize) : new UIFontDescriptor()) { if (IsItalic) { using (var descriptor2 = descriptor.CreateWithTraits(UIFontDescriptorSymbolicTraits.Italic)) { _native = UIFont.FromDescriptor(descriptor2, FontSize); } } else { _native = UIFont.FromDescriptor(descriptor, FontSize); } } #endif } return(_native); }
private static UIFont GetUIFont(string family, float size, FontAttributes attributes) { var bold = (attributes & FontAttributes.Bold) != 0; var italic = (attributes & FontAttributes.Italic) != 0; if (family != null) { try { UIFont result; if (UIFont.FamilyNames.Contains(family)) { var descriptor = new UIFontDescriptor().CreateWithFamily(family); if (bold || italic) { var traits = (UIFontDescriptorSymbolicTraits)0; if (bold) { traits = traits | UIFontDescriptorSymbolicTraits.Bold; } if (italic) { traits = traits | UIFontDescriptorSymbolicTraits.Italic; } descriptor = descriptor.CreateWithTraits(traits); result = UIFont.FromDescriptor(descriptor, size); if (result != null) { return(result); } } } result = UIFont.FromName(family, size); if (result != null) { return(result); } } catch { Debug.WriteLine("Could not load font named: {0}", family); } } if (bold && italic) { var defaultFont = UIFont.SystemFontOfSize(size); var descriptor = defaultFont.FontDescriptor.CreateWithTraits(UIFontDescriptorSymbolicTraits.Bold | UIFontDescriptorSymbolicTraits.Italic); return(UIFont.FromDescriptor(descriptor, 0)); } if (italic) { return(UIFont.ItalicSystemFontOfSize(size)); } if (bold) { return(UIFont.BoldSystemFontOfSize(size)); } return(UIFont.SystemFontOfSize(size)); }
RootElement MakeFonts() { Console.WriteLine("Changing"); // The baseline to show various adjustments you can make to a font baseline = UIFontDescriptor.PreferredBody; return(new RootElement("Fonts") { new Section() { new RootElement("System Preferred Fonts") { new Section() { new StyledStringElement("Headline") { Font = UIFont.PreferredHeadline }, new StyledStringElement("Subheadline") { Font = UIFont.PreferredSubheadline }, new StyledStringElement("Body") { Font = UIFont.PreferredBody }, new StyledStringElement("Caption1") { Font = UIFont.PreferredCaption1 }, new StyledStringElement("Caption2") { Font = UIFont.PreferredCaption2 }, new StyledStringElement("Footnote") { Font = UIFont.PreferredFootnote }, } }, new RootElement("Font weight") { new Section() { MakeSample("Body Plain", 0), MakeSample("Body Bold", UIFontDescriptorSymbolicTraits.Bold), MakeSample("Body Italic", UIFontDescriptorSymbolicTraits.Italic), } }, new RootElement("Line Spacing") { new Section() { MakeMultilineSample("Line Spacing; regular; " + lorem, 0), MakeMultilineSample("Line Spacing: tight; " + lorem, UIFontDescriptorSymbolicTraits.TightLeading), MakeMultilineSample("Line Spacing: loose; " + lorem, UIFontDescriptorSymbolicTraits.LooseLeading), } }, new RootElement("CoreText Font Features") { new Section("Use Proportional Number") { new StyledStringElement("10:20") { Font = Resize(UIFont.PreferredBody) }, new StyledStringElement("10:20") { Font = ResizeProportional(UIFont.PreferredBody) }, }, new Section("Use Character Alternatives") { new StyledStringElement("10:20") { Font = Resize(UIFont.PreferredBody) }, new StyledStringElement("10:20") { Font = ResizeAlternative(UIFont.PreferredBody) }, }, new Section("Use Proportional + Alternative") { new StyledStringElement("10:20") { Font = Resize(UIFont.PreferredBody) }, new StyledStringElement("10:20") { Font = ResizeProportionalAndAlternative(UIFont.PreferredBody) }, }, } }, }); }
static UIFont _ToNativeFont(string family, float size, FontAttributes attributes) { var bold = (attributes & FontAttributes.Bold) != 0; var italic = (attributes & FontAttributes.Italic) != 0; if (family != null && family != DefaultFontName) { try { UIFont result = null; if (UIFont.FamilyNames.Contains(family)) { var descriptor = new UIFontDescriptor().CreateWithFamily(family); if (bold || italic) { var traits = (UIFontDescriptorSymbolicTraits)0; if (bold) { traits = traits | UIFontDescriptorSymbolicTraits.Bold; } if (italic) { traits = traits | UIFontDescriptorSymbolicTraits.Italic; } descriptor = descriptor.CreateWithTraits(traits); result = UIFont.FromDescriptor(descriptor, size); if (result != null) { return(result); } } } if (family.StartsWith(".SFUI", System.StringComparison.InvariantCultureIgnoreCase)) { var fontWeight = family.Split('-').LastOrDefault(); if (!string.IsNullOrWhiteSpace(fontWeight) && System.Enum.TryParse <UIFontWeight>(fontWeight, true, out var uIFontWeight)) { result = UIFont.SystemFontOfSize(size, uIFontWeight); return(result); } result = UIFont.SystemFontOfSize(size, UIFontWeight.Regular); return(result); } result = UIFont.FromName(family, size); if (result != null) { return(result); } } catch { Debug.WriteLine("Could not load font named: {0}", family); } } if (bold && italic) { var defaultFont = UIFont.SystemFontOfSize(size); var descriptor = defaultFont.FontDescriptor.CreateWithTraits(UIFontDescriptorSymbolicTraits.Bold | UIFontDescriptorSymbolicTraits.Italic); return(UIFont.FromDescriptor(descriptor, 0)); } if (italic) { return(UIFont.ItalicSystemFontOfSize(size)); } if (bold) { return(UIFont.BoldSystemFontOfSize(size)); } return(UIFont.SystemFontOfSize(size)); }
public override void PreferredContentSizeChanged() { UIFontDescriptor descriptor = textView.Font.FontDescriptor; textView.Font = UIFont.GetPreferredFontForTextStyle(descriptor.FontAttributes.TextStyle); }
static UIFont _ToUIFont(string family, float size, FontAttributes attributes) { var bold = (attributes & FontAttributes.Bold) != 0; var italic = (attributes & FontAttributes.Italic) != 0; if (family != null) { try { UIFont result; if (UIFont.FamilyNames.Contains(family) && Forms.IsiOS7OrNewer) { var descriptor = new UIFontDescriptor().CreateWithFamily(family); if (bold || italic) { var traits = (UIFontDescriptorSymbolicTraits)0; if (bold) traits = traits | UIFontDescriptorSymbolicTraits.Bold; if (italic) traits = traits | UIFontDescriptorSymbolicTraits.Italic; descriptor = descriptor.CreateWithTraits(traits); result = UIFont.FromDescriptor(descriptor, size); if (result != null) return result; } } result = UIFont.FromName(family, size); if (result != null) return result; } catch { Debug.WriteLine("Could not load font named: {0}", family); } } if (bold && italic) { var defaultFont = UIFont.SystemFontOfSize(size); if (!Forms.IsiOS7OrNewer) { // not sure how to make a font both bold and italic in iOS 6, default to bold return UIFont.BoldSystemFontOfSize(size); } var descriptor = defaultFont.FontDescriptor.CreateWithTraits(UIFontDescriptorSymbolicTraits.Bold | UIFontDescriptorSymbolicTraits.Italic); return UIFont.FromDescriptor(descriptor, 0); } if (bold) return UIFont.BoldSystemFontOfSize(size); if (italic) return UIFont.ItalicSystemFontOfSize(size); return UIFont.SystemFontOfSize(size); }
static UIFont _ToUIFont(string family, float size, FontAttributes attributes) { var bold = (attributes & FontAttributes.Bold) != 0; var italic = (attributes & FontAttributes.Italic) != 0; if (string.IsNullOrWhiteSpace(family) && !string.IsNullOrWhiteSpace(Application.DefaultFontFamily)) { var s1 = Application.DefaultFontFamily; if (s1.Contains("#")) { s1 = s1.Substring(0, s1.IndexOf("#")); } if (s1.Contains(".ttf")) { s1 = s1.Substring(0, s1.IndexOf(".ttf")); } family = s1; } if (family != null) { try { UIFont result; if (UIFont.FamilyNames.Contains(family) && Forms.IsiOS7OrNewer) { var descriptor = new UIFontDescriptor().CreateWithFamily(family); if (bold || italic) { var traits = (UIFontDescriptorSymbolicTraits)0; if (bold) { traits = traits | UIFontDescriptorSymbolicTraits.Bold; } if (italic) { traits = traits | UIFontDescriptorSymbolicTraits.Italic; } descriptor = descriptor.CreateWithTraits(traits); result = UIFont.FromDescriptor(descriptor, size); if (result != null) { return(result); } } } result = UIFont.FromName(family, size); if (result != null) { return(result); } } catch { Debug.WriteLine("Could not load font named: {0}", family); } } if (bold && italic) { var defaultFont = UIFont.SystemFontOfSize(size); if (!Forms.IsiOS7OrNewer) { // not sure how to make a font both bold and italic in iOS 6, default to bold return(UIFont.BoldSystemFontOfSize(size)); } var descriptor = defaultFont.FontDescriptor.CreateWithTraits(UIFontDescriptorSymbolicTraits.Bold | UIFontDescriptorSymbolicTraits.Italic); return(UIFont.FromDescriptor(descriptor, 0)); } if (bold) { return(UIFont.BoldSystemFontOfSize(size)); } if (italic) { return(UIFont.ItalicSystemFontOfSize(size)); } return(UIFont.SystemFontOfSize(size)); }
public static UIFontDescriptor GetMonospacedDigitFontDescriptor(this UIFontDescriptor self) => self.CreateWithAttributes( new UIFontAttributes(new UIFontFeature( CTFontFeatureNumberSpacing.Selector.MonospacedNumbers )) );
public static UIFont ToUIFont(this Font self) { var size = (float)self.FontSize; if (self.UseNamedSize) { switch (self.NamedSize) { case NamedSize.Micro: size = 12; break; case NamedSize.Small: size = 14; break; case NamedSize.Medium: size = 17; // as defined by iOS documentation break; case NamedSize.Large: size = 22; break; default: size = 17; break; } } var bold = self.FontAttributes.HasFlag(FontAttributes.Bold); var italic = self.FontAttributes.HasFlag(FontAttributes.Italic); if (self.FontFamily != null) { try { if (UIFont.FamilyNames.Contains(self.FontFamily) && Forms.IsiOS7OrNewer) { var descriptor = new UIFontDescriptor().CreateWithFamily(self.FontFamily); if (bold || italic) { var traits = (UIFontDescriptorSymbolicTraits)0; if (bold) traits = traits | UIFontDescriptorSymbolicTraits.Bold; if (italic) traits = traits | UIFontDescriptorSymbolicTraits.Italic; descriptor = descriptor.CreateWithTraits(traits); return UIFont.FromDescriptor(descriptor, size); } } return UIFont.FromName(self.FontFamily, size); } catch { Debug.WriteLine("Could not load font named: {0}", self.FontFamily); } } if (bold && italic) { if (!Forms.IsiOS7OrNewer) { // not sure how to make a font both bold and italic in iOS 6, default to bold return UIFont.BoldSystemFontOfSize(size); } var defaultFont = UIFont.SystemFontOfSize(size); var descriptor = defaultFont.FontDescriptor.CreateWithTraits(UIFontDescriptorSymbolicTraits.Bold | UIFontDescriptorSymbolicTraits.Italic); return UIFont.FromDescriptor(descriptor, 0); } if (bold) return UIFont.BoldSystemFontOfSize(size); if (italic) return UIFont.ItalicSystemFontOfSize(size); return UIFont.SystemFontOfSize(size); }
public static UIFont ToNSFont(this Font self) #endif { var size = (float)self.FontSize; if (self.UseNamedSize) { switch (self.NamedSize) { case NamedSize.Micro: size = 12; break; case NamedSize.Small: size = 14; break; case NamedSize.Medium: size = 17; // as defined by iOS documentation break; case NamedSize.Large: size = 22; break; default: size = 17; break; } } var bold = self.FontAttributes.HasFlag(FontAttributes.Bold); var italic = self.FontAttributes.HasFlag(FontAttributes.Italic); if (self.FontFamily != null && self.FontFamily != DefaultFontName) { try { #if __MOBILE__ if (UIFont.FamilyNames.Contains(self.FontFamily)) { var descriptor = new UIFontDescriptor().CreateWithFamily(self.FontFamily); if (bold || italic) { var traits = (UIFontDescriptorSymbolicTraits)0; if (bold) { traits = traits | UIFontDescriptorSymbolicTraits.Bold; } if (italic) { traits = traits | UIFontDescriptorSymbolicTraits.Italic; } descriptor = descriptor.CreateWithTraits(traits); return(UIFont.FromDescriptor(descriptor, size)); } } return(UIFont.FromName(self.FontFamily, size)); #else var descriptor = new NSFontDescriptor().FontDescriptorWithFamily(self.FontFamily); if (bold || italic) { var traits = (NSFontSymbolicTraits)0; if (bold) { traits = traits | NSFontSymbolicTraits.BoldTrait; } if (italic) { traits = traits | NSFontSymbolicTraits.ItalicTrait; } descriptor = descriptor.FontDescriptorWithSymbolicTraits(traits); return(NSFont.FromDescription(descriptor, size)); } return(NSFont.FromFontName(self.FontFamily, size)); #endif } catch { Debug.WriteLine("Could not load font named: {0}", self.FontFamily); } } if (bold && italic) { var defaultFont = UIFont.SystemFontOfSize(size); #if __MOBILE__ var descriptor = defaultFont.FontDescriptor.CreateWithTraits(UIFontDescriptorSymbolicTraits.Bold | UIFontDescriptorSymbolicTraits.Italic); return(UIFont.FromDescriptor(descriptor, 0)); } if (italic) { return(UIFont.ItalicSystemFontOfSize(size)); } #else var descriptor = defaultFont.FontDescriptor.FontDescriptorWithSymbolicTraits( NSFontSymbolicTraits.BoldTrait | NSFontSymbolicTraits.ItalicTrait); return(NSFont.FromDescription(descriptor, 0)); }
public static UIFont ToUIFont(this Font self) { var size = (float)self.FontSize; if (self.UseNamedSize) { switch (self.NamedSize) { case NamedSize.Micro: size = 12; break; case NamedSize.Small: size = 14; break; case NamedSize.Medium: size = 17; // as defined by iOS documentation break; case NamedSize.Large: size = 22; break; default: size = 17; break; } } var bold = self.FontAttributes.HasFlag(FontAttributes.Bold); var italic = self.FontAttributes.HasFlag(FontAttributes.Italic); if (self.FontFamily != null) { try { if (UIFont.FamilyNames.Contains(self.FontFamily) && Forms.IsiOS7OrNewer) { var descriptor = new UIFontDescriptor().CreateWithFamily(self.FontFamily); if (bold || italic) { var traits = (UIFontDescriptorSymbolicTraits)0; if (bold) { traits = traits | UIFontDescriptorSymbolicTraits.Bold; } if (italic) { traits = traits | UIFontDescriptorSymbolicTraits.Italic; } descriptor = descriptor.CreateWithTraits(traits); return(UIFont.FromDescriptor(descriptor, size)); } } return(UIFont.FromName(self.FontFamily, size)); } catch { Debug.WriteLine("Could not load font named: {0}", self.FontFamily); } } if (bold && italic) { if (!Forms.IsiOS7OrNewer) { // not sure how to make a font both bold and italic in iOS 6, default to bold return(UIFont.BoldSystemFontOfSize(size)); } var defaultFont = UIFont.SystemFontOfSize(size); var descriptor = defaultFont.FontDescriptor.CreateWithTraits(UIFontDescriptorSymbolicTraits.Bold | UIFontDescriptorSymbolicTraits.Italic); return(UIFont.FromDescriptor(descriptor, 0)); } if (bold) { return(UIFont.BoldSystemFontOfSize(size)); } if (italic) { return(UIFont.ItalicSystemFontOfSize(size)); } return(UIFont.SystemFontOfSize(size)); }
public RadioButton_Mobile() { View = new UIView(); //Main statck layer.BorderWidth = 1.5f; layer.CornerRadius = 10; layer.BorderColor = UIColor.FromRGB(205, 205, 205).CGColor; Layer.AddSublayer(layer); //inner layer innerLayer.BorderWidth = 1.5f; innerLayer.CornerRadius = 10; innerLayer.BorderColor = UIColor.FromRGB(205, 205, 205).CGColor; mainStackView.Layer.AddSublayer(innerLayer); descriptor = new UIFontDescriptor().CreateWithFamily(amntLabl.Font.FamilyName); traits = traits | UIFontDescriptorSymbolicTraits.Bold; descriptor = descriptor.CreateWithTraits(traits); //heading hedinglbl.Text = "Complete your Payment"; hedinglbl.TextColor = UIColor.FromRGB(85, 85, 85); hedinglbl.Font = UIFont.FromDescriptor(descriptor, 20); mainStackView.AddSubview(hedinglbl); //payable payamountlabl.Text = "Total payable amount"; payamountlabl.TextColor = UIColor.Black; mainStackView.AddSubview(payamountlabl); //amount amntLabl.Text = "$120"; amntLabl.TextColor = UIColor.FromRGB(0, 125, 230); amntLabl.Font = UIFont.FromDescriptor(descriptor, 18); mainStackView.AddSubview(amntLabl); //amount selcetPaylbl.Text = "Select your payment mode"; mainStackView.AddSubview(selcetPaylbl); //RadioGroup sfr.Axis = UILayoutConstraintAxis.Vertical; sfr.Spacing = 20; netBanking.SetTitle("Net banking", UIControlState.Normal); netBanking.StateChanged += paymentMode_StateChanged; sfr.AddArrangedSubview(netBanking); debitCard.SetTitle("Debit card", UIControlState.Normal); debitCard.StateChanged += paymentMode_StateChanged; sfr.AddArrangedSubview(debitCard); creditCard.SetTitle("Credit card", UIControlState.Normal); creditCard.StateChanged += paymentMode_StateChanged; sfr.AddArrangedSubview(creditCard); mainStackView.AddSubview(sfr); View.AddSubview(mainStackView); button.SetTitle("Pay Now", UIControlState.Normal); button.SetTitleColor(UIColor.LightGray, UIControlState.Disabled); button.SetTitleColor(UIColor.White, UIControlState.Normal); button.TouchDown += Button_Clicked; button.BackgroundColor = UIColor.FromRGB(0, 125, 230); button.Enabled = false; alertView.Message = "Payment Successfull !"; alertView.AddButton("OK"); View.AddSubview(button); AddSubview(View); }
public static UIFont ToUIFont(this IFontElement self) { var family = self.FontFamily; var attributes = self.FontAttributes; var size = (float)self.FontSize; var bold = (attributes & FontAttributes.Bold) != 0; var italic = (attributes & FontAttributes.Italic) != 0; if (family != null && family != DefaultFontName) { try { UIFont result; if (UIFont.FamilyNames.Contains(family)) { var descriptor = new UIFontDescriptor().CreateWithFamily(family); if (bold || italic) { var traits = (UIFontDescriptorSymbolicTraits)0; if (bold) { traits = traits | UIFontDescriptorSymbolicTraits.Bold; } if (italic) { traits = traits | UIFontDescriptorSymbolicTraits.Italic; } descriptor = descriptor.CreateWithTraits(traits); result = UIFont.FromDescriptor(descriptor, size); if (result != null) { return(result); } } } result = UIFont.FromName(family, size); if (result != null) { return(result); } } catch { Debug.WriteLine("Could not load font named: {0}", family); } } if (bold && italic) { var defaultFont = UIFont.SystemFontOfSize(size); var descriptor = defaultFont.FontDescriptor.CreateWithTraits(UIFontDescriptorSymbolicTraits.Bold | UIFontDescriptorSymbolicTraits.Italic); return(UIFont.FromDescriptor(descriptor, 0)); } if (italic) { return(UIFont.ItalicSystemFontOfSize(size)); } if (bold) { return(UIFont.BoldSystemFontOfSize(size)); } return(UIFont.SystemFontOfSize(size)); }