Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6914941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:24:45+00:00 2026-05-27T09:24:45+00:00

Is there anyway in ios app to adjust the linespacing between the multiple lines

  • 0

Is there anyway in ios app to adjust the linespacing between the multiple lines in CCLabelTTF in cocos2d? Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T09:24:46+00:00Added an answer on May 27, 2026 at 9:24 am

    The answer to you question is no. You can’t adjust a CCLabelTTF linespacing. But hey! I will share with you my solution for this 😉

    This is the .h

    #import <Foundation/Foundation.h>
    #import "cocos2d.h"
    
    @interface CCLabelTTFLineSpaced : CCLayer {
    }
    
    + (id) labelWithString:(NSString*)string dimensions:(CGSize)dimensions alignment:(CCTextAlignment)alignment fontName:(NSString*)name fontSize:(CGFloat)size lineSpace:(CGFloat)space;
    
    - (id) initWithString:(NSString*)str dimensions:(CGSize)dimensions alignment:(CCTextAlignment)alignment fontName:(NSString*)name fontSize:(CGFloat)size lineSpace:(CGFloat)space;
    
    @end
    

    And this is the .m

    #import "CCLabelTTFLineSpaced.h"
    
    @implementation CCLabelTTFLineSpaced
    
    + (id) labelWithString:(NSString*)string dimensions:(CGSize)dimensions alignment:(CCTextAlignment)alignment fontName:(NSString*)name fontSize:(CGFloat)size lineSpace:(CGFloat)space{
        return [[[self alloc] initWithString: string dimensions:dimensions alignment:alignment fontName:name fontSize:size lineSpace:(CGFloat)space]autorelease];
    }
    
    - (id) initWithString:(NSString*)str dimensions:(CGSize)dimensions alignment:(CCTextAlignment)alignment fontName:(NSString*)name fontSize:(CGFloat)size lineSpace:(CGFloat)space{
        if( (self=[super init]) ) {
            anchorPoint_ = ccp(0.5f, 0.5f);
            [self setContentSize:dimensions];
            self.isRelativeAnchorPoint = NO;
    
            int pos = 0;
            int i = 0;
            while (pos<[str length]) {
                int end = 0;
                int lastCut = -1;
                bool finished=NO;
                while (finished==NO) {
                    CGSize actualSize = [[str substringWithRange:NSMakeRange(pos, end)] sizeWithFont:[UIFont fontWithName:name size:size]];
    
                    if (actualSize.width > dimensions.width || pos+end == [str length]) {
                        if (pos+end == [str length] && actualSize.width <= dimensions.width) lastCut = end;
                        finished=YES;
                    }
                    else {
                        if ([[str substringWithRange:NSMakeRange(pos+end, 1)] isEqualToString:@" "] || [[str substringWithRange:NSMakeRange(pos+end, 1)] isEqualToString:@"."] || [[str substringWithRange:NSMakeRange(pos+end, 1)] isEqualToString:@","]) {
                            lastCut = end;
                        }
                        end++;
                    }
                  }
    
                NSString * strLine = [str substringWithRange:NSMakeRange(pos, lastCut)];
    
                CCLabelTTF * line = [CCLabelTTF labelWithString:strLine dimensions:CGSizeMake(dimensions.width, size*2) alignment:alignment fontName:name fontSize:size];
                [line setAnchorPoint:ccp(0,1)];
                [line setPosition:ccp(0,-i*space)];
                [self addChild:line];
    
                pos=pos+lastCut;
                i++;
            }
        }
        return self;
    }
    @end
    

    Easy to use 😉 I have to complete the class with getters, setters and all stuff. I know that this is a “homemade” solution, but hey! It works!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

is there anyway I can access Ticker in my app? If so how can
I'm new to iOS development. Is there anyway to get FB SSO working with
I am new to iOS platform. Is there anyway I can use quartz composer
Is there anyway to access the native Facebook application (on iOS or Android) to
Is there any way to limit my iOS app be available for Gen 2
Is there anyway to have a sort of virtual static member in C++? For
Is there anyway to configure a WCF service with a failover endpoint if the
Is there anyway in Java to delete data (e.g., a variable value, object) and
Is there anyway to upgrade the installed JRE in the system? We are having
Is there anyway to declare an object of a class before the class is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.