0

imagePickerControl をカスタマイズしています

画像を選択するときに、ピッカーから mainView (ぼかし領域) へのアニメーションが必要ですが、良いアイデアはありますか?

4

1 に答える 1

0

基本的な考え方:

  1. 選択した画像で新しい temp-ImageView を作成します。
  2. これを元のImageViewの正確な位置でウィンドウに追加します。
  3. original-ImageView を削除します (必要に応じて)
  4. 画面上の目的の位置に temp-ImageView を移動/スケーリングします。
  5. 青い領域の目的の位置に final-ImageView を追加します。
  6. temp-ImageView を削除します。

- (CGRect)convertRect:(CGRect)rect fromView:(UIView *)view でいくつかの計算を行う必要があります。確かではありませんが、ピッカーは青い領域とは異なるウィンドウにある可能性があります。

CGRect destRect; // position in window, height/width need to be flipped, so the size is correct after rotation

// add a ContainerView so rotation-handling is easier, esp. durring moving/scaling
UIView *containerView = [[UIView alloc] initWithFrame:destRect];

// set the frame of the imageView, origin 0/0 so rotation is easy to handle, height/width flipp back
UIImageView *tempImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, destRect.size.height, destRect.size.width)];

// flip layer center as well
[tempImageView setCenter:CGPointMake(camView.center.y, camView.center.x)];

// add the rotation 
[tempImageView setTransform:CGAffineTransformMakeRotation(M_PI_2)];

[tempImageView setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight];
于 2012-04-28T08:55:02.747 に答える