Step 1: Create a Project.
* PanGestureRecognizer drag&drop to Image View.
Step 2: Add the images into your project.
Step 3: In .h File Add the Codings are,
#import <UIKit/UIKit.h>
@interface Touchviewcontroller : UIViewController
{
}
-(IBAction)handlePan:(UIPanGestureRecognizer *)recognizer;
@end
Step 4: In .m File Add the Codings are,
-(IBAction)handlePan:(UIPanGestureRecognizer *)recognizer
{
CGPoint translation = [recognizer translationInView:self.view];
recognizer.view.center = CGPointMake(recognizer.view.center.x + translation.x,
recognizer.view.center.y + translation.y);
[recognizer setTranslation:CGPointMake(0, 0) inView:self.view];
}
Step 5: In Xib File (Design)
* Create a Image View and assign the image.
* FileOwner --> Outlets --> Map the handlePan to PanGestureRecognizer.
No comments:
Post a Comment