Effectively render a Drop Shadow on a UIView subclass

Adding a drop shadow to your UIView subclass is as easy as the following code.

UIView *customView = [[UIView alloc] init];
...
customView.layer.shadowColor    = [[UIColor lightGrayColor] CGColor];
customView.layer.shadowOffset   = CGSizeMake(1, 1);
customView.layer.shadowOpacity  = 1.0;
customView.layer.shadowRadius   = 2.0; 
... 

While the common use case of such trick is on rendering stationary views, and no doubt it works perfectly that way, placing them inside a scrollable view like UISrollView or UITableView yields a different feel - it lags a bit when scrolling. So the way to solve this issue and keep them scrolling smoothly is to make use of UIBezierPath. You create an instance of this based on the `bounds` of the receiving view. Then set it as the `shadowPath` of the view's layer object.

UIBezierPath *path  = [UIBezierPath bezierPathWithRect:customView.bounds];
customView.layer.shadowPath = [path CGPath];

Now let's modify our base code to include the bezier path.

UIView *customView = [[UIView alloc] init];
...
UIBezierPath *path  = [UIBezierPath bezierPathWithRect:customView.bounds];
customView.layer.shadowPath = [path CGPath];

customView.layer.shadowColor    = [[UIColor lightGrayColor] CGColor];
customView.layer.shadowOffset   = CGSizeMake(1, 1);
customView.layer.shadowOpacity  = 1.0;
customView.layer.shadowRadius   = 2.0; 
... 

Trouble setting up iOS Push Notifications (APNS)

The following is caused by an invalid or outdated Provisioning Profile.
  • "no valid aps-environment entitlement found for application" (NSError displayed using NSLog)
  • "The entitlements specified in your application’s Code Signing Entitlements file do not match those specified in your provisioning profile" (displayed in Organizer window)
Take note that even if you're just updating an existing App ID in the Provisioning Portal, say you've just enabled this app's Push Notifications, you would also need to modify and re-submit the application's current Provisioning Profile (make sure that your test device is included in the list). After that, download and install this file, update Code Signing Identity section of your project's Build Settings to reflect the new profile (in xcode of course), then you're on to the next case.