-
-
Save dayitv89/e065831f1dda16353c46b523976a5ec9 to your computer and use it in GitHub Desktop.
Form shadow
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (CGPathRef)renderRect:(UIView*)imgView { | |
UIBezierPath *path = [UIBezierPath bezierPathWithRect:imgView.bounds]; | |
return path.CGPath; | |
} | |
- (CGPathRef)renderTrapezoid:(UIView*)imgView { | |
CGSize size = imgView.bounds.size; | |
UIBezierPath *path = [UIBezierPath bezierPath]; | |
[path moveToPoint:CGPointMake(size.width * 0.33f, size.height * 0.66f)]; | |
[path addLineToPoint:CGPointMake(size.width * 0.66f, size.height * 0.66f)]; | |
[path addLineToPoint:CGPointMake(size.width * 1.15f, size.height * 1.15f)]; | |
[path addLineToPoint:CGPointMake(size.width * -0.15f, size.height * 1.15f)]; | |
return path.CGPath; | |
} | |
- (CGPathRef)renderEllipse:(UIView*)imgView { | |
CGSize size = imgView.bounds.size; | |
CGRect ovalRect = CGRectMake(0.0f, size.height + 5, size.width - 10, 15); | |
UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect:ovalRect]; | |
return path.CGPath; | |
} | |
- (CGPathRef)renderPaperCurl:(UIView*)imgView { | |
CGSize size = imgView.bounds.size; | |
CGFloat curlFactor = 20.0f; | |
CGFloat shadowDepth = 8.0f; | |
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)]; | |
return path.CGPath; | |
} | |
- (void)loadView { | |
[super loadView]; | |
// Add background tile | |
UIImage *bgImage = [UIImage imageNamed:@"embedded_bg.png"]; | |
self.view.backgroundColor = [UIColor colorWithPatternImage:bgImage]; | |
// Add the reference view | |
UIImage *image = [UIImage imageNamed:@"dccp.jpeg"]; | |
UIImageView *imgView = [[UIImageView alloc] initWithImage:image]; | |
[self.view addSubview:imgView]; | |
imgView.center = self.view.center; | |
imgView.layer.shadowColor = [UIColor colorWithWhite:0 alpha:0.8].CGColor; | |
imgView.layer.shadowOpacity = 0.7f; | |
imgView.layer.shadowOffset = CGSizeMake(0.0f, 10.0f); | |
imgView.layer.shadowRadius = 5.0f; | |
imgView.layer.masksToBounds = NO; | |
// imgView.layer.shadowPath = [self renderRect:imgView]; | |
//imgView.layer.shadowPath = [self renderTrapezoid:imgView]; | |
//imgView.layer.shadowPath = [self renderEllipse:imgView]; | |
imgView.layer.shadowPath = [self renderPaperCurl:imgView]; | |
[imgView release]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment