Getting the center point of an NSView

前端 未结 3 1675
既然无缘
既然无缘 2021-02-19 19:16

I need to get the center point of a NSView in the form of a CGPoint, how can I achieve this? I am basically looking for the equivalent of the UIKit, UIView.center

3条回答
  •  花落未央
    2021-02-19 19:58

    This code will get you that CGPoint:

    CGPointMake((myView.frame.origin.x + (myView.frame.size.width / 2)),
                (myView.frame.origin.y + (myView.frame.size.height / 2)))
    

提交回复
热议问题