根據字體和文字來計算 UILable 的長度和大小
根據要顯示的文字以及UILable本身的字體,來計算能夠完全顯示所有文字的label所需要的大小,從而進行調整。
//Calculate the size necessary for the UILable NSString *theText = @"Texting"; CGSize theStringSize = [theText sizeWithFont:font constrainedToSize:theLabel.frame.size lineBreakMode:theLabel.lineBreakMode];//Adjust the size of the UILable theLable.frame = CGRectMake(theLable.frame.origin.x, theLable.frame.origin.y, theStringSize.width, theStringSize.height); theLable.text = theText;</pre>
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!