获取NSView的中心点 [英] Getting the center point of an NSView

查看:503
本文介绍了获取NSView的中心点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要以CGPoint的形式获取NSView的中心点,我该如何实现?
我基本上在寻找等效的UIKit,UIView.center

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

推荐答案

这段代码会让你CGPoint :

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)))

这篇关于获取NSView的中心点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆