NSString boundingRectWithSize returning unnecessarily tall height

前端 未结 4 1469
盖世英雄少女心
盖世英雄少女心 2021-01-30 18:12

When using [NSString boundingRectWithSize:options:attributes] the size of the rect that is returned is taller than I would expect for certain strings. The height re

4条回答
  •  粉色の甜心
    2021-01-30 18:52

    I tried the boundingRectWithSize function, but it didn't work for me.

    What did work was sizeThatFits

    Usage:

    CGSize maxSize = CGSizeMake(myLabel.frame.size.width, CGFLOAT_MAX)
    
    CGSize size = [myLabel sizeThatFits:maxSize];
    

提交回复
热议问题