I have a custom UIScrollView in my app. When the user touches the scroll view I want it to enlarge to fill the entire screen.
I have tried using this code, however nothing happens :
-(void) touchesBegan: (NSSet *) touches withEvent:(UIEvent *) event {
NSLog(@"Touch Detected");
self.frame = CGRectMake(0, 0, 768, 1024);
}
Is there a way to dynamically change the size of the view ? Also is it possible to somehow animate the change in size ?
Thank you in advance.
Your code looks correct. Perhaps your view is clipped within a parent view making it seem as though it didn’t resize, in which case you should be mindful of the
clipsToBoundsproperty of the parent view. Some other considerations (without knowing what makes you think its not working) is thecontentModeproperty of your UIScrollView. Depending on that value, your UIScrollView may not be redrawing itself. See UIView for details (readframeproperty)Animate example:
Details on animate: UIView (read
animateWithDuration:animations:class method).