在Swift中旋转NSImageView

时间:2015-03-22 23:49:56

标签: swift nsimage nsimageview

我使用游乐场旋转下面的图像。

 let imagePath = pathToFileInSharedSubfolder("gauge.png")
 let image = NSImage(byReferencingFile: imagePath)!


let imageView = NSImageView()
imageView.image = image

//Frames
let imageframe = imageView.frame
let origin = CGPointMake(imageframe.width/2, 0)
imageView.setFrameOrigin(origin)
imageView.rotateByAngle(35)
imageView.setNeedsDisplay()
let frame = CGRectMake(150, 0, 51, 126)
imageView.frame = frame
view.addSubview(imageView)

let refImageView = NSImageView()
refImageView.frame = frame
refImageView.image = image

view.addSubview(refImageView)

图像不是围绕我的原点旋转。见下图?

如何更改图像视图原点?感谢。

enter image description here

0 个答案:

没有答案