ios - Why NSLineBreakByWordWrapping splits word? -


with using nsattributedstring, tried create text inside triangle below;

http://postimg.org/image/rp9fukgaj/

i used "nslinebreakbywordwrapping" method fitting text inside defined shape. first word of text splits , couldn't found solution that. want text jumps following line instead of splitting. how can that?

below code used;

- (void)viewdidload {     [super viewdidload];     self.view.backgroundcolor=[uicolor blackcolor];     ctfontref fontref = ctfontcreatewithname((cfstringref)@"helveticaneue-regular", 15.0f, null);          nsmutableparagraphstyle* paragraph = [nsmutableparagraphstyle new];     paragraph.headindent = 10;     paragraph.firstlineheadindent = 10;     paragraph.tailindent = -10;     paragraph.linebreakmode = nslinebreakbywordwrapping;     paragraph.alignment = nstextalignmentcenter;     paragraph.paragraphspacing = 15;         nsdictionary *attrdictionary = [nsdictionary dictionarywithobjectsandkeys: (__bridge id)fontref, (nsstring *)kctfontattributename, (id)[[uicolor whitecolor] cgcolor], (nsstring *)(kctforegroundcolorattributename),paragraph,nsparagraphstyleattributename, nil];         cfrelease(fontref);     nsattributedstring *attstring = [[nsattributedstring alloc] initwithstring:@"initially, create paragraph style , apply first character. note how margins dictated: tailindent negative, bring right margin leftward, , firstlineheadindent must set separately, headindent not automatically apply first line." attributes:attrdictionary];     [(customview *)[self view] setattstring:attstring]; } 

checking out documentation nslinebreakmode, apparently if word not fit on given line, word broken fit. if text static, insert newline character skip first part of triangle; otherwise, you'll have clever figure out how overcome limitation.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -