拖动UIButton时移动拖动手柄

时间:2012-02-27 19:03:42

标签: objective-c ios uiview uibutton uiimage

我有一个视图,其中包含响应拖动事件的UIButtons。一切正常,问题是按钮只有70X70,拖动时按钮的图像很大程度上被手指遮住(过程是用户将图像(UIButton)拖动到视图上的目标区域) 。有没有办法抵消拖动手柄,因此它不是UIButton的中心点?理想情况下,我希望它是UI按钮图像的右上角,因为左下角是我最关心用户看到的区域。

编辑:这是我用来处理触摸(拖动)事件的代码:

- (IBAction) imageTouch:(id) sender withEvent:(UIEvent *) event
{
    UIButton *thisButton = (UIButton *)sender;

    CGPoint centerPoint = [[[event allTouches] anyObject] locationInView:self.view];
    UIControl *control = sender;
    control.center = centerPoint;

    UIColor *selColor = [WebImageOperations getColorFromImage:self.targetImageView.image atX:point.x andY:point.y];

    NSInteger thisScore = [Scoring scoreFromUIColor:selColor withArrow:thisButton.tag];

    switch (thisButton.tag) {
        case 10:
            arrow10Score = thisScore;
            self.score10Label.text = [NSString stringWithFormat:@"%d", arrow10Score];
            break;
        case 12:
            arrow12Score = thisScore;
            self.score12Label.text = [NSString stringWithFormat:@"%d", arrow12Score];
            break;
        case 14:
            arrow14Score = thisScore;
            self.score14Label.text = [NSString stringWithFormat:@"%d", arrow14Score];
            break;

        default:
            break;
    }

    NSInteger totalScore = arrow10Score + arrow12Score + arrow14Score;
    self.totalScoreLabel.text = [NSString stringWithFormat:@"%d", totalScore];
}

1 个答案:

答案 0 :(得分:0)

我不认为这是可能的。如果有人遇到这个问题并有解决方案,请在此发布,我会将答案标记为正确答案。