title: How can I convert the following code about CGContext into Swift3
body: <p>Just like the headline ,I have some Objective-c code ,how can I use them in Swift3</p>
  
  <pre><code>CGContextSaveGState(context);
  CGContextSetTextMatrix(context, CGAffineTransformIdentity);
  CGContextTranslateCTM(context, 0, size.height);
  CGContextScaleCTM(context, 1.0, -1.0);
  
  CGMutablePathRef path = CGPathCreateMutable();
  CGPathAddRect(path, NULL, CGRectMake(0, 0, size.width, size.height));
  NSMutableAttributedString *attri = [[NSMutableAttributedString alloc]initWithString:_text];
  [attri addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:10] range:NSMakeRange(0, _text.length)];
  
  CTFramesetterRef ctFramesetting = CTFramesetterCreateWithAttributedString((CFAttributedStringRef)attri);
  CTFrameRef ctFrame = CTFramesetterCreateFrame(ctFramesetting, CFRangeMake(0, attri.length), path, NULL);
  CTFrameDraw(ctFrame, context);
  
  CFRelease(path);
  CFRelease(ctFramesetting);
  CFRelease(ctFrame);
  </code></pre>