I have a subclassed UIView loaded from nib and I cannot get a shadow to draw around it. I have been trying to get a shadow to appear around the whole species for quite some time. I decided to place it in my own sublevel in order to simplify its animation later. Here is the code:
-(void)awakeFromNib { self.clipsToBounds = NO; // set up the shadow layer CALayer *shadow = [CALayer layer]; shadow.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, self.bounds.size.width, self.bounds.size.height); shadow.shadowColor = [UIColor blueColor].CGColor; shadow.shadowRadius = 15.0; shadow.opacity = 1.0; [self.layer addSublayer:shadow]; // I set this property so I have access to it later to more easily animate it. self.shadowLayer = shadow; }
When I NSLog shadowLayer property, the coordinates and frame are correct. It corresponds to the view that it supports.
I also set the border color and corner radius to self.layer and it displays correctly. If I put the shadow on self.layer , it will appear, but it covers all the children of my parent UIView .
Any help is greatly appreciated.
source share