動態計算控制元件高度

weixin_33809981發表於2018-03-23

+ (CGRect)createSize:(NSString *)lableStr andFont:(NSInteger)fondS andSize:(CGSize)mysize andName:(NSString *)name;

{

    UIFont *font;

    if (name.length == 0)

    {

        font=[UIFont systemFontOfSize:fondS];

    }else

    {

        font=[UIFont fontWithName:name size:fondS];

    }

    CGRect rect=[lableStr boundingRectWithSize:mysize options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName] context:nil];

    return rect;

}

相關文章