【发布时间】:2016-03-05 22:08:39
【问题描述】:
我正在尝试旋转放置在 rect 内且仅覆盖其中一部分的图像。
我已经找到了这个解决方案,但无法旋转图像:
override func drawRect(rect: CGRect) {
let context = UIGraphicsGetCurrentContext()
// drawing some texts and lines
// rotate myImage by 'angle'
CGContextSaveGState(context)
CGContextTranslateCTM(context, imageOffset.x, imageOffset.y)
CGContextRotateCTM(context, angle)
CGContextTranslateCTM(context, -imageOffset.x, -imageOffset.y)
myImage?.drawInRect(CGRect(x: imageOffset.x, y: imageOffset.y, width: imageSize.width, height: imageSize.height))
CGContextRestoreGState(context)
// draw other stuff
}
那么,如何正确地做呢?
【问题讨论】:
标签: ios image rotation core-graphics image-rotation