iOS開発NSString文字列の一定の高さ/幅に基づいて文字列が占める幅/高さを返す
1018 ワード
#pragma mark - / /
/**
* @brief / /
* @category
* @param goalString
* @param font;
* @param fixedSize; /
* @param isWidth; ( / )
**/
// ( / , ) /
+ (CGSize)getStringSizeWith:(NSString *)goalString withStringFont:(CGFloat)font withWidthOrHeight:(CGFloat)fixedSize isWidthFixed:(BOOL)isWidth{
CGSize sizeC ;
if (isWidth) {
sizeC = CGSizeMake(fixedSize ,MAXFLOAT);
}else{
sizeC = CGSizeMake(MAXFLOAT ,fixedSize);
}
CGSize sizeFileName = [goalString boundingRectWithSize:sizeC
options:NSStringDrawingUsesLineFragmentOrigin
attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:font]}
context:nil].size;
return sizeFileName;
}