通过文字大小来计算按钮宽度
作者:
月沉眠love | 来源:发表于
2019-07-02 14:47 被阅读0次
按钮宽度
/**
按钮宽度
*/
-(CGSize)buttonSizeOfTitle:(NSString*)title
{
NSStringDrawingOptions opts = NSStringDrawingUsesLineFragmentOrigin |
NSStringDrawingUsesFontLeading;
NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
[style setLineBreakMode:NSLineBreakByTruncatingTail];
NSDictionary *attributes = @{ NSFontAttributeName : [UIFont systemFontOfSize:ButtonFontSelectedSize], NSParagraphStyleAttributeName : style };
CGSize textSize = [title boundingRectWithSize:CGSizeMake(_topScrollView.bounds.size.width, TopScrollViewHeight)
options:opts
attributes:attributes
context:nil].size;
return textSize;
}
本文标题:通过文字大小来计算按钮宽度
本文链接:https://www.haomeiwen.com/subject/lfwzcctx.html
网友评论