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

Add vertical alignment controls #1

Open
lilyball opened this issue Jan 4, 2010 · 2 comments
Open

Add vertical alignment controls #1

lilyball opened this issue Jan 4, 2010 · 2 comments
Labels

Comments

@lilyball
Copy link
Owner

lilyball commented Jan 4, 2010

Add a property for vertical alignment of the text in the FontLabel.

@vbergae
Copy link

vbergae commented Apr 13, 2011

+1

@vbergae
Copy link

vbergae commented Apr 19, 2011

Hi! I've an issue related with this.

I have a FontLabel instantiated using a system font (not ZFont). Works fine ands display my texts, the is the size for the label. I'm using sizeWithFont:constrainedToSize:lineBreakMode: for calculate the desired FontLabel size but appears that the font size is more bigger than the real size used in FontLabel and all my texts are vertical centered. I didn't found a solution navigating in the code if anybody has an idea please tell me.

Example:

// Instantiate the font label ant ZFont

    FontLabel text = [[FontLabel alloc] initWithFrame:CGRectNull];

    ZFont *zFont = [ZFont fontWithUIFont:[UIFont systemFontOfSize:15.0]];

    NSDictionary *attributes = [NSDictionary 
                                dictionaryWithObjectsAndKeys:
                                zFont, ZFontAttributeName, nil];

    ZMutableAttributedString *str = [[[ZMutableAttributedString alloc] 
                                     initWithString:@"A very very large string......."
                                     attributes:attributes] 
                                     autorelease];

   text.zAttributedText = str;

// Calculates size for the text

     CGSize expectedSize = [str.string sizeWithFont:[UIFont systemFontOfSize:15.0]
                                             constrainedToSize:CGSizeMake(9999,9999) 
                                                   lineBreakMode:UILineBreakModeWordWrap]; 

// Creates the rect

      [text setFrame:CGRectMake(0,0,expectedSize.width, expectedSize.height)];

The resultant rect is (points area spaces):

+-----------------------------------+

|................................................ |

|................................................ |

|................................................ |

| Very very large sfsdfsdfdf |

| string bla bla bla bla bla b |

|................................................ |

|................................................ |

|................................................ |

+-----------------------------------+

The result size doesn't adjust to the text and appears vertical centered.

Thanks!

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

No branches or pull requests

2 participants