-
16进制的颜色转换
class func rgbaColor(rgb:Int,alphe:CGFloat) -> UIColor
{
return UIColor (red:((CGFloat)((rgb & 0xFF0000)>>16))/255.0,green:((CGFloat)((rgb & 0xFF00)>>8))/255.0,blue:((CGFloat)(rgb & 0xFF))/255.0,alpha:alphe)
} -
计算文本的高度
class func textHeight(textString:String,textWidth:CGFloat,textHeight:CGFloat,textFont:Float) -> CGSize {
let size = CGSize(width:textWidth,height:textHeight)
var size2 = CGSize()size2 = textString.boundingRect(with: size, options: NSStringDrawingOptions.usesLineFragmentOrigin, attributes: NSDictionary(object:UIFont.systemFont(ofSize: CGFloat(textFont)), forKey: NSFontAttributeName as NSCopying) as? [String : Any] ,context: nil).size return size2 }
网友评论