Skip to content
This repository has been archived by the owner on Sep 18, 2021. It is now read-only.

TUIAttributtedString: CTParagraphStyle not kept #86

Open
erndev opened this issue Dec 4, 2011 · 0 comments
Open

TUIAttributtedString: CTParagraphStyle not kept #86

erndev opened this issue Dec 4, 2011 · 0 comments

Comments

@erndev
Copy link

erndev commented Dec 4, 2011

I am using a TUIAttributted string, and i found a problem. When i set the lineheight, the Alignment/linebreak properties i previously defined are ignored, and the text is drawn using the default properties.

I located the problem in these functions:

  • (void)setLineHeight:(CGFloat)f inRange:(NSRange)range
  • (void)setAlignment:(TUITextAlignment)alignment lineBreakMode:(TUILineBreakMode)lineBreakMode

In those methods, a new CTParagraphStyle object is created, but each method only sets the values for the values received, ignoring the values previously set.

The solution would be to recreate the CTParagrahStyleRef object with all the expected properties.
I could fix it, but my doubt is how to implement it .
The easiest way seemed to keep ivars for those values and recreate the CTParagraphStyle object, but currently, those methods belong to the NSMutableAttributedString (TUIAdditions) category, and categories cannot have ivars.

I can see other options:

  • Moving those methods to the TUIAttributtedString class, and adding ivars for those values.
  • Reading current CTParagrahStyleRef and changing only the modified values, but i think this solution is worse.
  • add a new method setAlignment:lineBreakMode:lineHeight , but this is not maintainable if more paragraph styles are added in the future.

any suggestion?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant