非正方形NSButton [英] Non-square NSButton

查看:162
本文介绍了非正方形NSButton的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何创建带有非方形命中区的NSButton?

How to create a NSButton with non-square "hit area"?

示例:

img src =https://i.stack.imgur.com/ru4VZ.pngalt =enter image description here>

感谢。

推荐答案

你可以子类NSButton并覆盖 hitTest:您希望可点击。 ( [super hitTest:] )。

You could probably subclass NSButton and override hitTest: to return nil when outside the area you want to be clickable. (Return [super hitTest:] when inside.)

此处的文档。 / a>

Docs here.

这篇关于非正方形NSButton的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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