私はこのコードをで使用して、内部にタッチドラッグIBAction
でを作成しUIImageView
ています: UIButton
-(IBAction) addNewPhoto:(id)sender{
switch ([sender tag]) {
case 0:{
imageMove = [UIImage imageNamed:@"knet.jpg"];
holderView = [[UIView alloc] initWithFrame:CGRectMake(0,0, imageMove.size.width, imageMove.size.height)];
UIImageView *imageview = [[UIImageView alloc] initWithFrame:[holderView frame]];
[imageview setImage:imageMove];
[holderView addSubview:imageview];
UIPinchGestureRecognizer *pinchRecognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(scale:)];
[pinchRecognizer setDelegate:self];
[holderView addGestureRecognizer:pinchRecognizer];
UIRotationGestureRecognizer *rotationRecognizer = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotate:)];
[rotationRecognizer setDelegate:self];
[holderView addGestureRecognizer:rotationRecognizer];
UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(move:)];
[panRecognizer setMinimumNumberOfTouches:1];
[panRecognizer setMaximumNumberOfTouches:1];
[panRecognizer setDelegate:self];
[holderView addGestureRecognizer:panRecognizer];
UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapped:)];
[tapRecognizer setNumberOfTapsRequired:1];
[tapRecognizer setDelegate:self];
[holderView addGestureRecognizer:tapRecognizer];
[self.view addSubview:holderView];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:.5];
[superView setFrame:CGRectMake(0, 0, 320, 550)];
//[holderView setFrame:CGRectMake(0, 0, 320, 550)];
//holderView.alpha = 1;
[UIView commitAnimations];
}
break;
case 1:
{
imageMove = [UIImage imageNamed:@"test.jpg"];
//..........similar to case 0 but another picture
}
break;
default:
break;
}
ボタンは内側にありますscrollView
。私が探しているのは、ユーザーがボタンから指をドラッグしたところに画像を作成し、指を離さなくてもボタンを動かせるようにする必要があるということです。
このブログの画像を移動、ズーム、回転するためのソースコードを使用しましたが、UIImagePickerControllerではなくボタンを使用して画像を作成するように変更しました。