0

I want to curve inside the top border of UIView like this,

enter image description here

I've tried many ways like UIBezierPath etc.

Help needed.

Community
  • 1
  • 1
Hxb
  • 79
  • 9
  • 1
    Try UIBezierPath again ;) – David Rönnqvist Feb 25 '15 at 07:45
  • If UIBezierPath won't help than create image like above curve and set it as background of your view. – Kampai Feb 25 '15 at 07:52
  • @Kampai : Actually i'm working with CAShapeLayer. There are multiple layers so i'm looking for some UIBezierPath solution. – Hxb Feb 25 '15 at 07:58
  • Well i figured it out. Animate the whole view. During animation change the **self.view.origin.y** to below. Now on completion set **self.view.origin.y** to its original position. NSInteger option = UIViewAnimationCurveEaseInOut; orgRect = self.frame; CGRect tempRect = orgRect; tempRect.origin.y = tempRect.origin.y+20; [UIView animateWithDuration:0.05 delay:0.0 usingSpringWithDamping:0.5 initialSpringVelocity:0.5 options:option animations:^{ self.frame = tempRect; } completion:^(BOOL flag){ self.frame = orgRect; }]; – Hxb Feb 25 '15 at 11:31

1 Answers1

0

You can do that using UIBezierPath, Have a look at this answer,

UIBezierPath *maskPath;
maskPath = [UIBezierPath bezierPathWithRoundedRect:_backgroundImageView.bounds 
                             byRoundingCorners:(UIRectCornerBottomLeft | UIRectCornerBottomRight) 
                                   cornerRadii:CGSizeMake(3.0, 3.0)];

CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = self.bounds;
maskLayer.path = maskPath.CGPath;
_backgroundImageView.layer.mask = maskLayer;
[maskLayer release];

With this we can draw the rounded corners to any side of view. But If you want to draw rounded edge, Better to take a background image to view.

Community
  • 1
  • 1
Saif
  • 2,678
  • 2
  • 22
  • 38