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
ありがとうございます。コード –
を追加した可能性があります。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 /#ドキュメント/ UIKit /リファレンス/ UIButton_Class/UIButton/UIButton.html#// apple_ref/occ/instp/UIButton/imageEdgeInsets – Melvin