How to create UINavigationBar drop shadow

后端 未结 4 1714
臣服心动
臣服心动 2020-12-22 21:09

Would like to know create drop shadow for UINavigationbar. I tried to create custom navigation bar background with drop shadow, but the drop shadow cover the background view

4条回答
  •  隐瞒了意图╮
    2020-12-22 21:54

    In applyDefaultStyle, try adding this line:

    self.layer.masksToBounds = NO;
    

    The default value for this property is YES, which means that even though the shadow is rendered, it won't be rendered outside the bounds of the view, which means effectively that you don't see it at all.

    If you're animating this view in any way, you should also add this line:

    self.layer.shouldRasterize = YES;
    

    ... unless you want the animation to be slow and jerky.

提交回复
热议问题