嘗試這種方式找到的寬度和文本的高度然後設置標籤尺寸
var participantCountLabel: UILabel=UILabel(frame: CGRectMake(100, 100, 10, 40));
participantCountLabel.text = "\(participantCount) participants"
var strText:NSString=participantCountLabel.text!
let styleLineBreakWordWrap : NSMutableParagraphStyle=NSMutableParagraphStyle()
styleLineBreakWordWrap.lineBreakMode=NSLineBreakMode.ByWordWrapping
styleLineBreakWordWrap.alignment=NSTextAlignment.Left
var attributes:NSDictionary=[NSFontAttributeName : participantCountLabel.font,
NSParagraphStyleAttributeName:styleLineBreakWordWrap]
strText.sizeWithAttributes(attributes);
var maximumLabelSize : CGSize=CGSizeMake(1000, 100)
var textRect: CGRect=strText.boundingRectWithSize(maximumLabelSize, options: NSStringDrawingOptions.UsesLineFragmentOrigin, attributes: attributes, context: nil)
participantCountLabel.frame.size=textRect.size;
self.toolbarLeftButton.customView = participantCountLabel