Graphics Reference
In-Depth Information
Figure 4.11
Using
shadowPath
to cast shadows with arbitrary shapes
Listing 4.4
Creating Simple Shadow Paths
@interface
ViewController ()
@property
(
nonatomic
,
weak
)
IBOutlet
UIView
*layerView1;
@property
(
nonatomic
,
weak
)
IBOutlet
UIView
*layerView2;
@end
@implementation
ViewController
- (
void
)viewDidLoad
{
[
super
viewDidLoad
];
//enable layer shadows
self
.layerView1.
layer
.
shadowOpacity
=
0.5f
;
self
.layerView2.
layer
.
shadowOpacity
=
0.5f
;
//create a square shadow
CGMutablePathRef
squarePath =
CGPathCreateMutable
();
CGPathAddRect
(squarePath,
NULL
,
self
.layerView1.
bounds
);
self
.layerView1.
layer
.
shadowPath
= squarePath;
CGPathRelease
(squarePath);
//create a circular shadow