TUIAttributtedString: CTParagraphStyle not kept
Opened this issue · 0 comments
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?