Skip to content


Subversion checkout URL

You can clone with
Download ZIP


I os7 fixes #163

merged 7 commits into from

4 participants


No description provided.


We should check whether an empty string returns 0 height, as it was returning pre-iOS 7.


NSLog(@"%@", NSStringFromCGSize([@"" sizeWithFont:[UIFont systemFontOfSize:14]]));

  • (on iOS <7): {0, 0}
  • (on iOS ≥7): {0, 17}

Oh, and:

NSLog(@"%@", NSStringFromCGSize([@"" sizeWithAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:14.0]}])) -> {0, 16.309999}

In iOS 7, you will get a bigger vertical margin compared to iOS pre-7.


An empty string ([text length] == 0) would return CGSizeZero on iOS 7 using MB_TEXTSIZE, wouldn't it?

Sorry, I think I'm tired. Ultimately I'm missing stuff. Didn't notice the short conditional.

This is good. Elb-approved :+1:

Sorry but this is not properly working. As said, on iOS 7 the behavior of the old sizeWithFont has changed. So, your code is not working properly (returns height > 0) if the hud will be displayed on a iOS7 device and [text lenght] == 0. This means that such conditional switch against the text length should be performed also in the #else branch of the macro.

As a side note, using a nil pointer instead of @"" returns 0 height.


You are right. Should be fixed in e7b7493.

On a side note, I'm perhaps adding the height when the string is empty @"" is in fact the better way to handle this. Like you said, you could always set the string to nil, if you don't want that extra space.

Just for notice, after you calculate size by this method: boundingRectWithSize:maxSize options (NSStringDrawingUsesLineFragmentOrigin) attributes:@{NSFontAttributeName:font} context:nil].size

You must use ceilf function, to works properly. From official docs:

This method returns fractional sizes (in the size component of the returned CGRect); to use a returned size to size views, you must use raise its value to the nearest higher integer using the ceil function.
@matej matej merged commit 5c87948 into master
@matej matej deleted the iOS7 branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 30, 2013
  1. @Vyazovoy @matej

    Applied this recommendations:…

    Vyazovoy authored matej committed
    Added .pch file speed up compilation time.
  2. @Vyazovoy @matej

    Little typo fix.

    Vyazovoy authored matej committed
  3. @matej
  4. @matej

    Added iOS 7 resources to the demo project.

    matej authored
    - new icon size (+ missing existing icon sizes)
    - new launch images (+ updated iOS 6 images)
    - a convenient screenshot mode setting
  5. @matej

    Added new Xcode shareddata.

    matej authored
  6. @matej

    Using iOS 7 text size methods, when deploying to iOS 7+.

    matej authored
    - circumvents deprication warnings
Commits on Jul 1, 2013
  1. @matej
Something went wrong with that request. Please try again.