2

I need to fold/unfold the edge of UIImageView to mark as a favorite. I searched across multiple sites, but have not found anything about it.

I attached some example images, and, if possible, with animation effect.

Fold Fold 2

TylerH
  • 20,799
  • 66
  • 75
  • 101
mhergon
  • 1,688
  • 1
  • 18
  • 39

3 Answers3

1

One way to do it would be to animate the view usign OpenGL. There is a nice library for that called XBPageCurl

However, you could achieve a much lighter solution by creating a mask for the curl effect and animate your view while transitioning to it. Here is what it would look like

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.3];

UIImage *maskedImage = [yourImage imageMaskedWithImage:yourMask];
[yourImageView setImage:maskedImage];

[UIView commitAnimations];

To know how to mask an image, have a look here http://mobiledevelopertips.com/cocoa/how-to-mask-an-image.html

nicolasthenoz
  • 1,852
  • 1
  • 13
  • 14
0

can be done with UIViewController's presentModalViewController:animated: and setting the modalTransistionStyle to UIModalTransitionStylePartialCurl. See apple's docs.

Kai Huppmann
  • 10,705
  • 6
  • 47
  • 78
  • Kai, thanks, but fold effect should be tiny on any edge of UIImageView, so I can not use the default animation. – mhergon Sep 19 '12 at 13:58
0
@IBAction func curl(_ sender: Any, forEvent event: UIEvent) {
    
    if b == 1 {
    UIView.transition(with: imageview, duration: 1.5, options: .transitionCurlUp, animations: {self.imageview.isHidden = true}, completion: nil)
        b = 2
    }
    else if b == 2
    {
        self.imageview.isHidden  = false
        UIView.transition(with: imageview, duration: 1.5, options: .transitionCurlDown, animations: {self.imageview.isHighlighted = true}, completion: nil)
        b = 1
    }
}
Peter Csala
  • 17,736
  • 16
  • 35
  • 75
mAj
  • 31
  • 2
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 18 '21 at 10:56