话不多说,上代码。
任何继承自UIView的空间都是有layer这个属性的。(header 是一个控件)
UIBezierPath *shadowPath = [UIBezierPath bezierPathWithRect:header.bounds];
header.layer.masksToBounds = NO;
header.layer.shadowColor = HKDefaultPlaceColor.CGColor;//阴影颜色
header.layer.shadowOffset = CGSizeMake(0, 5);//阴影偏移量:X向左为负
header.layer.shadowOpacity = 0.5f;//阴影透明度
header.layer.shadowPath = shadowPath.CGPath;