拖动进入时突出显示按钮 [英] Highlight the button when drag enter

查看:23
本文介绍了拖动进入时突出显示按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

刚开始探索iOS SDK.我有一些按钮,需要突出显示它们在外面接触一次然后拖动.据我了解,当您单击按钮然后向外拖动然后再次向内拖动时,会触发 TouchDragEnter 事件.在按钮外部单击然后向内拖动时是否会触发任何事件?

just started to explore iOS SDK. I have some buttons, need to highlight them touching outside once and then drag. As I understand, TouchDragEnter event fires when you click the button then drag outside then drag inside again. Is there any event fires when you click outside the button and then drag inside?

推荐答案

Alexander,

在搜索相同信息时,我发现您的问题尚未得到解答.您可能已经想通了,但我是这样做的.

Searching for the same info, I saw your question hadn't been answered. You've probably already figured it out, but here's how I've done it.

注意 pointInside:withEvent: 方法检查点是否位于按钮的边界内.由于触摸事件来自视图,因此您必须将其转换为按钮的坐标系.

Note that the pointInside:withEvent: method checks to see if the point lies within the button's bounds. Since the touch event is coming from the view, you have to convert it to the button's coordinate system.

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
for (UITouch *t in touches) {
    CGPoint touchPoint = [t locationInView:self.view];

    CGPoint testPoint = [self.view convertPoint:touchPoint toView:aButton];
    if ([aButton pointInside:testPoint withEvent:event]) {
        //Do something
    }
    //rest of code

这篇关于拖动进入时突出显示按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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