2010-04-19 5 views
1

Est-il possible de diviser le texte en paragraphe dans un UITextView?Création de paragraphes dans UITextview

+4

Veuillez donner plus de détails et accepter certaines de vos questions précédentes. – pheelicks

+0

Bonjour, J'ai un uitextview et quand je commence à écrire il devrait commencer comme le début du paragraphe après un certain espace. est-ce possible? Merci, – milanjansari

Répondre

4

C'est possible.

Exemple:

UITextView *testTextView = [[UITextView alloc] initWithFrame:frame]; 

[testTextView setText:@"More\nBooks"]; 

Il est affiché comme 2 cordes:

Plus

Livres

clé pour la réponse est: \n - fin de symboles de ligne. Utilisez NSMutableParagraphStyle dans la chaîne attribuée.

0

et vérifiez les autres propriétés au lieu de paragraphSpacingBefore;

NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; 
      paragraphStyle.paragraphSpacingBefore = 33.; 

_textView.attributedText = [[NSAttributedString alloc] initWithString:string attributes:@{NSParagraphStyleAttributeName: paragraphStyle}];