I want to draw following shape. I have used bezier path but could not make those two corner curved. I have used
- (void)addArcWithCenter:(CGPoint)center radius:(CGFloat)radius startAngle:(CGFloat)startAngle endAngle:(CGFloat)endAngle clockwise:(BOOL)clockwise
- (void)addCurveToPoint:(CGPoint)endPoint controlPoint1:(CGPoint)controlPoint1 controlPoint2:(CGPoint)controlPoint2
- (void)addQuadCurveToPoint:(CGPoint)endPoint controlPoint:(CGPoint)controlPoint
but instead of giving curved line it's giving straight line.
Any idea how to do this.
CGFloat deltaX=0;
CGFloat deltaY=0;
CGFloat deltaXX=0;
CGFloat deltaYY=0;
CGFloat deltaXXX=0;
CGFloat deltaYYY=0;
CGFloat deltaXXXX=0;
CGFloat deltaYYYY=0;
CGFloat controlPoint1X=0;
CGFloat controlPoint1Y=0;
CGFloat controlPoint2X=0;
CGFloat controlPoint2Y=0;
deltaX=self.centrePoint.x+(currentPoint.x-self.centrePoint.x)/4;
deltaY=self.centrePoint.y;
deltaXX=self.centrePoint.x+(currentPoint.x-self.centrePoint.x)*3/8;
deltaYY=self.centrePoint.y + (currentPoint.y-self.centrePoint.y)/4;
deltaXXX=self.centrePoint.x+(currentPoint.x-self.centrePoint.x)*5/8;
deltaYYY=self.centrePoint.y+(currentPoint.y-self.centrePoint.y)*3/4;
deltaXXXX=self.centrePoint.x+(currentPoint.x-self.centrePoint.x)*3/4;
deltaYYYY=currentPoint.y;
controlPoint1X=deltaXX+(deltaXXX-deltaXX)/2;
controlPoint1Y=deltaYY+(deltaYYY-deltaYY)/2;
controlPoint2X=deltaXXX+(deltaXXXX-deltaXXX)/2;
controlPoint2Y=deltaYYY+(deltaYYYY-deltaYYY)/2;
CGPoint pointOne=CGPointMake(deltaX, deltaY);
CGPoint pointTwo=CGPointMake(deltaXX, deltaYY);
CGPoint pointThree=CGPointMake(deltaXXX, deltaYYY);
CGPoint pointFour=CGPointMake(deltaXXXX, deltaYYYY);
CGPoint controlPointOne=CGPointMake(controlPoint1X, controlPoint1Y);
CGPoint controlPointTwo=CGPointMake(controlPoint2X, controlPoint2Y);
UIBezierPath* aPath = [[UIBezierPath alloc]init];
[aPath moveToPoint:self.centrePoint];
[aPath setLineWidth:2.0f];
[[UIColor blueColor] setFill];
[aPath addLineToPoint:pointOne];
[aPath moveToPoint:pointOne];
[aPath addQuadCurveToPoint:pointTwo controlPoint:controlPointOne];
[aPath moveToPoint:pointTwo];
[aPath addLineToPoint:pointThree];
[aPath moveToPoint:pointThree];
[aPath addQuadCurveToPoint:pointFour controlPoint:controlPointTwo];
[aPath addLineToPoint:currentPoint];
[aPath stroke];
for(UIBezierPath *bPath in self.arrPaths){
[bPath stroke];
}
[self.arrPaths addObject:aPath];