Getting the center point of an NSView

前端 未结 3 1597
既然无缘
既然无缘 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:52

    To get an NSPoint of the center, you can just get the x-coordinate of the origin and add (width/2), and get the y-coordinate of the origin and add (height/2). Then you can convert it into a CGPoint.

提交回复
热议问题