简体   繁体   English

自定义非矩形按钮三角形状

[英]Custom Non Rectangular Buttons Triangular shape

I want to use triangle type buttons on image but i am unable to do this... 我想在图像上使用三角形按钮,但我无法做到这一点......

How to do this? 这该怎么做?

This project can help you. 这个项目可以帮到你。 you can customize the shape of the UIButton . 您可以自定义UIButton的形状。

All UIViews - all of them - are rectangles. 所有UIViews - 都是 - 矩形。 You cannot make a UIView that is a triangle, but you can make one that contains and presents a triangular shape and responds only to touches within that shape. 你不能制作一个三角形的UIView,但你可以制作一个包含并呈现三角形的形状,并仅响应该形状内的触摸。 You must understand of course that underneath it all, it's a rectangle, and you'll have to handle the case wherein the user touches outside of the triangle but inside of the rectangle, probably by passing such events through to views below. 你当然必须明白,在它下面,它是一个矩形,你必须处理用户触摸三角形外部但在矩形内部的情况,可能是通过将这些事件传递到下面的视图。 Indeed, you might have to handle all touch event combinations (touch down inside, touch up outside, touch move outside, etc) in this way. 实际上,您可能必须以这种方式处理所有触摸事件组合(触摸内部,触摸外部,触摸移动到外部等)。

Maybe the project referenced above will handle all this, I didn't look too deeply. 也许上面引用的项目将处理所有这些,我看起来并不太深。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM