Compartilhar via


UITextView.AttributedText Propriedade

Definição

Conteúdo da exibição de texto como uma cadeia de caracteres atribuída.

[ObjCRuntime.Introduced(ObjCRuntime.PlatformName.iOS, 6, 0, ObjCRuntime.PlatformArchitecture.All, null)]
public virtual Foundation.NSAttributedString AttributedText { [ObjCRuntime.Introduced(ObjCRuntime.PlatformName.iOS, 6, 0, ObjCRuntime.PlatformArchitecture.All, null)] [Foundation.Export("attributedText", ObjCRuntime.ArgumentSemantic.Copy)] get; [ObjCRuntime.Introduced(ObjCRuntime.PlatformName.iOS, 6, 0, ObjCRuntime.PlatformArchitecture.All, null)] [Foundation.Export("setAttributedText:", ObjCRuntime.ArgumentSemantic.Copy)] set; }
member this.AttributedText : Foundation.NSAttributedString with get, set

Valor da propriedade

Atributos

Comentários

Os desenvolvedores de aplicativos devem usar essa propriedade se desejarem o uso de vários estilos de texto no UITextView. O exemplo a seguir usa M:Foundation.NSMutableAttributableString.AddAttribute* para modificar a cor e a fonte em vários intervalos, conforme mostrado na imagem.

//UITextView default
var atts = new UIStringAttributes();
atts.ForegroundColor = UIColor.Blue;
var txt = "Text Kit.\n Lorem ipsum different font dolor sit amet, consectetur adipiscing elit.";
var attributedString = new NSMutableAttributedString(txt,atts);

//Multiple type styles. 
attributedString.BeginEditing();
attributedString.AddAttribute(UIStringAttributeKey.ForegroundColor, UIColor.Red, new NSRange(0, 10));
attributedString.AddAttribute(UIStringAttributeKey.Font, UIFont.PreferredFontForTextStyle(UIFontTextStyle.Headline), new NSRange(0, 10));
attributedString.AddAttribute(UIStringAttributeKey.Font, UIFont.FromName("Georgia", 20), new NSRange(23, 14));
attributedString.EndEditing();

TextView.AttributedText = attributedString;

Aplica-se a

Confira também