Friday, 15 August 2014

iphone - How to set Line Spacing in UI Text View (Empty text view) to enter message with line space -



iphone - How to set Line Spacing in UI Text View (Empty text view) to enter message with line space -

in app need set line spacing on ui text view..

i know can non editable textviews / labels using paragraph style spacing

but in app when come in text not working,

i can when have predefined text on it, if 1 time clear text paragraph sty not work

nsmutableparagraphstyle *paragraphstyle = [[nsmutableparagraphstyle alloc] init]; paragraphstyle.minimumlineheight = 35.f; paragraphstyle.maximumlineheight = 35.f; uifont *font = [uifont fontwithname:@"americantypewriter" size:18.f]; nsstring *string = @"this test"; nsdictionary *attributtes = @{ nsparagraphstyleattributename : paragraphstyle, }; deedtextview.font = font; deedtextview.attributedtext = [[nsattributedstring alloc] initwithstring:string attributes:attributtes];

but, dont have pre defined text nsstring *string = @"this test";

text view must empty, while begin

i had same problem. based on sergius reply came next working solution. problem sergius reply other set attributes overwritten (font, color...)

so improve edit existing typingattributes:

nsdictionary* d = deedtextview.typingattributes; nsmutabledictionary* md = [nsmutabledictionary dictionarywithdictionary:d]; [md setobject:paragraphstyle forkey:nsparagraphstyleattributename]; deedtextview.typingattributes= md;

iphone objective-c uitextview nsattributedstring

No comments:

Post a Comment