UIButton:需要一个圆圈击中区域 [英] UIButton: Need a circle hit area

查看:183
本文介绍了UIButton:需要一个圆圈击中区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的我有6个自定义UIButton。它们的正常状态图像都是圆形图像。
它们都是相同的间隔,但是所有圆圈都互相接触。

Ok I have 6 custom UIButtons. Their normal state image are all circles images. They are all spaced out equally but all the circles touch each other.

自定义UI按钮(其上有圆形图像)的问题是,该按钮的命中区域是方形的,并且该方块的角落与另一个自定义按钮的hitarea的hitarea重叠。

The problem with the custom UIbutton (which has a circle image on it), is that the hit area of that button is square, and the corners of this square overlaps the hitarea of the other custom button's hitarea.

如何制作一个命中区域UI按钮,正常状态有一个圆形图像,只能在那个圆圈上点击,而不是正常的方形命中区域?!

How do i make the hit area of a UIbutton whos normal state has a circle image, be only clickable on that circle only, rather than the normal square hit area?!

我希望有人可以找到一个方法我解决了目前我遇到的这个问题!

I hope that someone can find a way for me to solve this problem that i currently am having!

提前致谢

Pavan

推荐答案

如果单击圆圈的方形区域,则应检查圆心与坐标之间的距离咔嗒声小于圆的半径。如果没有,则可以忽略命中。

If the square area of a "circle" is clicked on, you should then check if the distance between the center of the circle and the coordinates of the click are less than the radius of the circle. If not, then the "hit" can be ignored.

这篇关于UIButton:需要一个圆圈击中区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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