Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Supporting Attributed String in SLKTextView #501

Merged
4 commits merged into from
Aug 7, 2016
Merged

Conversation

ghost
Copy link

@ghost ghost commented Aug 7, 2016

We wanted to support attributed string in our SLKTextView to allow more stylization on the text we input. This PR will change SLKTextView to use NSAttributedString by default. To be backward compatible, all the original API will be preserved, and in places where we insert NSString for the text, the string will be converted into NSAttributedString without any attributes assigned to it.
There are additional API provided to allow ease of stylization.

@ghost ghost assigned dzenbot Aug 7, 2016
- (NSRange)slk_insertText:(NSString *)text inRange:(NSRange)range
{
// Skip if the text is empty
if (text.length == 0) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably best to check that text is not nil.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, nevermind. This param is nonnull.

[super setText:text];

if (text) {
[self setAttributedText:[[NSAttributedString alloc] initWithString:text]];
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whenever we need to create an attributed string out of a string, with no attributes, let's take the textView's font and textColor properties so it renders with the expected default styling.

Jacky Wu and others added 2 commits August 7, 2016 00:51
@ghost
Copy link
Author

ghost commented Aug 7, 2016

👍 nice, thank you for cleaning it up! should we merge this?

@dzenbot
Copy link

dzenbot commented Aug 7, 2016

👍👍

@ghost ghost merged commit e5beed3 into master Aug 7, 2016
@dzenbot dzenbot deleted the attributed-string-support branch August 8, 2016 06:28
@dzenbot dzenbot mentioned this pull request Oct 4, 2016
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant