Reputation: 7466
I am developing an app, that has support for customizing fonts, colors etc. in design time. You just swap a plist and the app has a different style,color,s etc.. This works, i need to have it like that . So far so good. Some buttons have titles. I use two different custom fonts for two different builds.
The problem is, using the other font causes the titleLabels in all buttons to be offset 5 point to the TOP. I can't use some "hacky "way to move the offset 5 px up. Since it wll coause the first font to be offset 5 px up.
I am not really sure if the problme is in my code, or in the source font file.
The label is centered horizontaly and verticaly. Is there any other way to generalize the code so that it would handle that offset difference?
Upvotes: 1
Views: 133
Reputation: 38249
compare like this:
CGSize firstStringSize = [myString sizeWithFont:firstFont]; //get size for first string with its font
CGSize secondStringSize = [myString sizeWithFont:secondFont]; //get size for second string with its font
if(!CGSizeEqualToSize(firstStringSize, secondStringSize)) //checking for both are not equal
{
if(firstStringSize.height > secondStringSize.height)
//secondStringSize offset 5 px
if(secondStringSize.height > firstStringSize.height)
//firstStringSize offset 5 px
}
Upvotes: 1