rcw

Top Corners Rounded

rcw
Apr 12th, 2016
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CALayer *capa = [self.navigationController navigationBar].layer;
  2. [capa setShadowColor: [[UIColor blackColor] CGColor]];
  3. [capa setShadowOpacity:0.85f];
  4. [capa setShadowOffset: CGSizeMake(0.0f, 1.5f)];
  5. [capa setShadowRadius:2.0f];  
  6. [capa setShouldRasterize:YES];
  7.  
  8.  
  9. //Round
  10. CGRect bounds = capa.bounds;
  11. bounds.size.height += 10.0f;    //I'm reserving enough room for the shadow
  12. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:bounds
  13.                                                byRoundingCorners:(UIRectCornerTopLeft | UIRectCornerTopRight)
  14.                                                      cornerRadii:CGSizeMake(10.0, 10.0)];
  15.  
  16. CAShapeLayer *maskLayer = [CAShapeLayer layer];
  17. maskLayer.frame = bounds;
  18. maskLayer.path = maskPath.CGPath;
  19.  
  20. [capa addSublayer:maskLayer];
  21. capa.mask = maskLayer;
Advertisement