什么类子类 - NSView或NSButton [英] What class to subclass - NSView or NSButton

查看:102
本文介绍了什么类子类 - NSView或NSButton的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个按钮,我应该继承NSView和NSButton吗?

I am creating a button and should I subclass NSView and or NSButton?

推荐答案

如果你只想做自定义绘图,请考虑子类化 NSButtonCell ,这是负责在按钮内绘制的类。如果这不够强大到能做你想要的,你应该继承NSButton,因为它将免费给你很多行为,并将允许你在Interface Builder中设置按钮,就像任何其他控件一样。

If you only want to do custom drawing, consider subclassing NSButtonCell, which is the class responsible for drawing within a button. If that's not powerful enough to do what you want, you should subclass NSButton, as it'll give you lots of behavior for free, and will let you set up the button in Interface Builder as you would any other control.

这篇关于什么类子类 - NSView或NSButton的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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