下面的代码不会为Rect1,2,3
绘制CGRectlet context = UIGraphicsGetCurrentContext()
let Rect1 = CGRect(x:30, y:200, width:300, height: 50)
let Rect2 = CGRect(x:30, y:260, width:300, height: 50)
let Rect3 = CGRect(x:30, y:320, width:300, height: 50)
CGContextAddRect(context,Rect1)
CGContextAddRect(context,Rect2)
CGContextAddRect(context,Rect3)
CGContextsetFillColorWithColor(context, UIColor.blueColor().CGColor)
CGContextFillRect(Context,Rect1)
CGContextFillRect(Context,Rect2)
CGContextFillRect(Context,Rect3)
let str1: NSString =" Hello"
let str2: NSString =" How are u?"
let str3: NSString =" See u"
let font = UIFont(name: "Helvetica Neue", size: 18.0)
let textcolor:UIColor = UIColor.whiteColor()
let attr = [NSFontAttributedName:font,
NSForegroundColorAttributedName: textColor]
str1.drawInREct(Rect1, withAttributes: attr)
str2.drawInREct(Rect2, withAttributes: attr)
str3.drawInREct(Rect3, withAttributes: attr)
....
感谢。