Swift calculates label dynamic width and height
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 (, 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
}
Swift calculates label dynamic width and height