视图添加移动手势

-(void)createMoveImageView

{

    _moveImageView=[[UIImageView alloc]initWithImage:[_backgroundImageView.image blurredImageWithRadius:20 iterations:10 tintColor:nil]];

    _moveImageView.userInteractionEnabled=YES;

    _moveImageView.frame=CGRectMake(0, 0, 100, 100);

    _moveImageView.layer.borderWidth =1.0;

    _moveImageView.layer.borderColor=[UIColor whiteColor].CGColor;

    [self.view addSubview:_moveImageView];

    UIPanGestureRecognizer *panGR = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGRAction:)];

    [_moveImageView addGestureRecognizer:panGR];

}

// 移动

- (void)panGRAction:(UIPanGestureRecognizer *)paramSender{

    

    CGPoint point = [paramSender translationInView:self.view];

    paramSender.view.center = CGPointMake(paramSender.view.center.x + point.x, paramSender.view.center.y + point.y);

    [paramSender setTranslation:CGPointMake(0, 0) inView:self.view];

    

}


你可能感兴趣的:(基础控件)