-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCALayer+Additions.m
More file actions
36 lines (29 loc) · 1.02 KB
/
CALayer+Additions.m
File metadata and controls
36 lines (29 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//
// CALayer+Additions.m
// evisita
//
// Created by Gabi Martelo on 28/11/13.
// Copyright (c) 2013 Startcapps. All rights reserved.
//
#import "CALayer+Additions.h"
@implementation CALayer (Additions)
/**
* Create a shadow above or below a UIView
*
* @param frame a CGRect with the frame for the shadow
* @param toBottom a BOOL indicating if the shadow will be draw to the bottom
* @return a CALayer with the shadow to add as sublayer
*/
+ (CALayer *)createShadowWithFrame:(CGRect)frame toBottom:(BOOL)toBottom
{
CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.frame = frame;
UIColor* lightColor = [[UIColor blackColor] colorWithAlphaComponent:0.0];
UIColor* darkColor = [[UIColor blackColor] colorWithAlphaComponent:0.3];
if (toBottom)
gradient.colors = [NSArray arrayWithObjects:(id)darkColor.CGColor, (id)lightColor.CGColor, nil];
else
gradient.colors = [NSArray arrayWithObjects:(id)lightColor.CGColor,(id)darkColor.CGColor, nil];
return gradient;
}
@end