我正在尝试按照以下步骤设置label的字体,但它为此提供了零CGSize

UIFont *abbrFont = [UIFont fontWithName:@"Helvetica Cyrillic Bold_5" size:50]; //Helvetica Cyrillic Bold_5 added Custom Font

CGSize abbrSizeOfString = [_addbrTitle sizeWithFont:abbrFont];//_addbrTitle is a NSString
NSLog(@"%f %f",abbrSizeOfString.width,abbrSizeOfString.height); //Everytime Prints (0.000,0.000)


帮我解决这个问题。

谢谢。

最佳答案

尝试这个,

UIFont *abbrFont = [UIFont fontWithName:@"Helvetica" size:50]; //Helvetica Cyrillic Bold_5 added Custom Font
CGSize abbrSizeOfString = [_addbrTitle.text sizeWithFont:abbrFont];//_addbrTitle is a Label
NSLog(@"%f %f",abbrSizeOfString.width,abbrSizeOfString.height); //E

10-06 05:57