仅缩放叠加图像

时间:2013-03-21 11:23:26

标签: iphone ios objective-c uiimageview image-zoom

我的相机覆盖中有一个叠加图像。当用户双击我的overlayimage时,我需要放大/缩小。

叠加图像代码:

UIImageView *overlayImageView = [[UIImageView alloc] 
initWithImage:[UIImage imageNamed:@"overlay.png"]];
[overlayImageView setFrame:CGRectMake(30, 100, 260, 200)];
[[self view] addSubview:overlayImageView];
[overlayImageView release];

1 个答案:

答案 0 :(得分:2)

- (void)viewDidLoad {
    [super viewDidLoad];

    UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapGesture:)];
    tapGesture.numberOfTapsRequired = 2;
    [overlayImageView addGestureRecognizer:tapGesture]; // add tapGesture to your ImageView
    [tapGesture release];

  self.isTouch == YES; // it is BOOL type.
}

 - (void)handleTapGesture:(UITapGestureRecognizer *)sender 
{
        if(self.isTouch)
        {
              // put relavent size of Zoom ImageView
            self.isTouch == NO;
        }
        else
        {
              // put code for normal ImageView
              self.isTouch == YES;
        }
}