0
我有一个视图具有响应拖动事件的UIButton。这一切都正常工作,问题是该按钮只有70X70,拖动时用于手指的按钮图像大部分被手指遮住(该过程是用户拖动图像(UIButton)到视图上的目标区域) 。有没有办法来抵消拖动手柄,所以它不是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];
}
给我们一些代码。 – Melvin 2012-02-27 22:22:06
有你去。添加代码 – 2012-02-28 10:29:44
可能是https://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIButton_Class/UIButton/UIButton.html#//apple_ref/occ/instp/UIButton/contentEdgeInsets或https:// developer .apple.com/library/ios /#DOCUMENTATION/UIKit/Reference/UIButton_Class/UIButton/UIButton.html#// apple_ref/occ/instp/UIButton/imageEdgeInsets – Melvin 2012-02-28 11:32:31