在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
func getLabHeigh(labelStr:String,font:UIFont,width:CGFloat) -> CGFloat { let statusLabelText: NSString = labelStr let size = CGSizeMake(width, 900) let dic = NSDictionary(object: font, forKey: NSFontAttributeName) let strSize = statusLabelText.boundingRectWithSize(size, options: .UsesLineFragmentOrigin, attributes: dic as? [String : AnyObject], context: nil).size return strSize.height }
func getLabWidth(labelStr:String,font:UIFont,height:CGFloat) -> CGFloat { let statusLabelText: NSString = labelStr let size = CGSizeMake(900, height) let dic = NSDictionary(object: font, forKey: NSFontAttributeName) let strSize = statusLabelText.boundingRectWithSize(size, options: .UsesLineFragmentOrigin, attributes: dic as? [String : AnyObject], context: nil).size return strSize.width } |
请发表评论