UIPanGesture does not expand UIImageView when superview expands

Monday, May 5, 2014

I have a pangestures attached to a view's corner in my view controller. The idea is to expand or shrink the view. Inside the view I have a UIImageview. When a pangesture expands the view, the UIImageview is not expanding eventhough autosizing subviews is enabled on the superview. I also did change the UIImageview frame to be equal the superview bound. What I see on the screen is the UIImage retains its original frame, and the superview background starts showing.

any idea what I might be doing wrong?

- (IBAction)handleLR:(UIPanGestureRecognizer *)gesture
CGPoint point = [gesture translationInView:self.aView];
CGFloat witdth = point.x;
CGFloat height = point.y;
if((self.aView.frame.size.width<= 1*self.LR.frame.size.width) && point.x<0)
witdth = -(startingRect.size.width - 1.0*self.UR.frame.size.width);
point = CGPointMake( witdth, height );

if((self.aView.frame.size.height<= 2.0*self.LR.frame.size.height) && point.y <0)
height = -(startingRect.size.height - 2.0*self.UR.frame.size.height);
point = CGPointMake(witdth, height);

if(gesture.state == UIGestureRecognizerStateBegan)
startingRect = self.aView.frame;
NSLog(@" imageview %f %f", self.imageview.frame.size.width, self.imageview.frame.size.height);
else if ( gesture.state == UIGestureRecognizerStateChanged)

CGRect rect = CGRectMake(startingRect.origin.x,
startingRect.size.width +point.x, startingRect.size.height +point.y);
self.aView.frame = rect;
self.UR.center = CGPointMake(self.LR.center.x,
self.LR.center = CGPointMake(self.UL.center.x + self.aView.frame.size.width,
self.UL.center.y + self.aView.frame.size.height);
self.LL.center = CGPointMake(self.UL.center.x,

// here I am resizing the UIImageview frame to expand with the superview
self.imageview.bounds = self.aView.bounds;