Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have masked image successfully with the help of following link:

How to Mask an UIImageView

In above link there are two images named image.png and mask.png ,

After masking the image i want to crop the result image.

My concern is that I want to crop the image named image.png but mask.png should be stay still as it is. I am using KICropImageView https://github.com/zhangzhixun/CropImageDemo for cropping the Image.

But when I scroll the image my whole result image is scrolling but I just want to scroll image.png not mask.png image.

Any idea how can I do that?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
145 views
Welcome To Ask or Share your Answers For Others

1 Answer

You Can Use PanGesture..

- (void)viewDidLoad
{ 

[super viewDidLoad];

UIPanGestureRecognizer *pan1 = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePanImage:)];

self.imageview.userInteractionEnabled = YES;

[self.imageview addGestureRecognizer:pan1];

}

**after called Method handlePanImage..**

- (void)handlePanImage:(UIPanGestureRecognizer *)sender

{

 static CGPoint originalCenter;

 if (sender.state == UIGestureRecognizerStateBegan)


 {

 originalCenter = sender.view.center;

        sender.view.alpha = 0.8;

        [sender.view.superview bringSubviewToFront:sender.view];

    }

    else if (sender.state == UIGestureRecognizerStateChanged)

    {
        CGPoint translation = [sender translationInView:self.view];

        sender.view.center = CGPointMake(originalCenter.x + translation.x, originalCenter.y + translation.y);

    }

    else if (sender.state == UIGestureRecognizerStateEnded || sender.state == UIGestureRecognizerStateCancelled || sender.state == UIGestureRecognizerStateFailed)
    {
        // do whatever post dragging you want, e.g.
        // snap the piece into place

        [UIView animateWithDuration:0.2 animations:^{
            CGPoint center = sender.view.center;
            center.x = round(center.x / 50.0) * 50.0;
            center.y = round(center.y / 50.0) * 50.0;
            sender.view.center = center;
            sender.view.alpha  = 1.0;
        }];
    }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...