Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignores newline characters #12

Open
AndrewWestberg opened this issue Sep 20, 2012 · 6 comments
Open

Ignores newline characters #12

AndrewWestberg opened this issue Sep 20, 2012 · 6 comments

Comments

@AndrewWestberg
Copy link

In the standard UILabel, a newline character \n causes a line break. In this component, the newline characters gets trimmed out and are not respected.

@LemonCake
Copy link
Owner

Noted. Will add support to this.

@adamotte
Copy link

MSLabel works great thx.
Up for newline characters !

@99handmade
Copy link

Hi,
I just wrote a short code to fix the newline issue, here ti is :
///////////////////////////////////////////////////////////////////////////////////////////////
NSMutableArray * newSlicedString = [NSMutableArray array];

for (NSString * str in slicedString) {
    NSArray * newArray = [str componentsSeparatedByString:@"\n"];
    for (NSString * ns in newArray) {
        [newSlicedString addObject:ns];
    }
}
return newSlicedString;

////////////////////////////////////////////////////////////////////////////////////////////////
add this code at the end of the method - (NSArray *)stringsFromText:(NSString *)string in the file MSLabel.m

anyway, MSLabel is a great work, thanks for the author.

@LemonCake
Copy link
Owner

Hey thanks for the piece of code. Would you mind making a pull request for this so you can get credit for the change? :)

@nuthinking
Copy link

Had same issues sorted with:

- (void)drawTextInRect:(CGRect)rect
{
    NSArray *lines = [self.text componentsSeparatedByString:@"\n"];
    NSMutableArray *slicedStrings = [[NSMutableArray alloc] init];
    for(NSString *line in lines){
        [slicedStrings addObjectsFromArray:[self stringsFromText:line]];
    }
...

@tasomaniac
Copy link

Is it merged? I came accross the same problem. It is a dealbreaker for me. I have spent hours before understanding it is related to MSLabel.

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

No branches or pull requests

6 participants