小编Man*_*har的帖子

在视图ios xcode上用手指移动和旋转图像

用手指移动和旋转图像


- (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)

image move objective-c ios

0
推荐指数
1
解决办法
4120
查看次数

标签 统计

image ×1

ios ×1

move ×1

objective-c ×1