I wanted to have a special pagecurl effect on top of a UIImageView. After some Google'ing it doesn't seem that hard to do and so I created a small project to showcase it.
The pagecurl effect just uses some Quartz-properties on the underling CALayer of UIImageView, more specifically the border
and shadow
properties. Below's the code to set the border and shadow, and you can download the NWImageView
class which implements the pagecurl-border.
[objc]
self.layer.borderColor = [UIColor whiteColor].CGColor;
self.layer.borderWidth = 10.;
CGSize size = self.bounds.size;
CGFloat curlFactor = 15.0f;
CGFloat shadowDepth = 5.0f;
self.layer.shadowColor = [UIColor blackColor].CGColor;
self.layer.shadowOpacity = 1.f;
self.layer.shadowOffset = CGSizeMake(.0f, 5.0f);
self.layer.shadowRadius = 5.0f;
self.layer.masksToBounds = NO;
UIBezierPath *path = [UIBezierPath bezierPath];
[path moveToPoint:CGPointMake(0.0f, 0.0f)];
[path addLineToPoint:CGPointMake(size.width, 0.0f)];
[path addLineToPoint:CGPointMake(size.width, size.height + shadowDepth)];
[path addCurveToPoint:CGPointMake(0.0f, size.height + shadowDepth)
controlPoint1:CGPointMake(size.width - curlFactor, size.height + shadowDepth - curlFactor)
controlPoint2:CGPointMake(curlFactor, size.height + shadowDepth - curlFactor)];
self.layer.shadowPath = path.CGPath;
[/objc]