【发布时间】:2012-02-27 19:03:41
【问题描述】:
我有一个视图,它具有响应拖动事件的 UIButtons。一切正常,问题是按钮只有 70X70,并且在拖动时,按钮的图像在很大程度上被手指覆盖(过程是用户将图像(UIButton)拖动到视图上的目标区域) .有没有办法偏移拖动手柄,使其不是 UIButton 的中心点?理想情况下,我希望它位于 UIbutton 图像的右上角,因为左下角是我最关心用户看到的区域。
编辑:这是我用来处理触摸(拖动)事件的代码:
- (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];
}
【问题讨论】:
-
那条评论有什么建设性的?我知道大部分 UIButton 属性和方法。这种评论完全没有价值,除非您可以提供代码示例,表明在该类上使用某些方法将有助于解决我提出的问题。
标签: objective-c ios uiview uibutton uiimage