- (void)viewDidLoad
{
self.imageview.image = [UIImage imageNamed:@"Image.png"];
[self.view addSubview: self.imageview];
[super viewDidLoad];
}
Run Code Online (Sandbox Code Playgroud)
此代码用于移动图像
-(void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event
{
UITouch *touch = [[event allTouches] anyObject];
CGPoint touchLocation = [touch locationInView:touch.view];
self.imageview.center = touchLocation;
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
// get touch event
UITouch *touch = [[event allTouches] anyObject];
CGPoint touchLocation = [touch locationInView:self.PlayVideo];
if ([touch view] == self.view)
{
self.imageview.center = touchLocation;
}
}
Run Code Online (Sandbox Code Playgroud)
此代码用于旋转图像(T将旋转手势放到图像上并拖到.h文件中)
- (IBAction)regRotation:(UIGestureRecognizer *)sender
{
NSLog(@"rotation");
CGFloat netRotation =0.0;
CGFloat rotation =[(UIRotationGestureRecognizer *)sender rotation];
CGAffineTransform …Run Code Online (Sandbox Code Playgroud)