Вам нужно начать путь и закрыть его, когда вы закончите.Ваш второй вызов CGContextAddLineToPoint все портит, я думаю.Вот фрагмент кода, который работает.Изучите его и улучшите, чтобы он поддерживал несколько ваших дел (кажется, вы хотите иметь возможность округлять только некоторые углы, а не обязательно все из них ...)
void addRoundedRect(CGContextRef ctx, CGRect rect, float cornerRadius) {
if (cornerRadius <= 2.0) {
CGContextAddRect(ctx, rect);
} else {
float x_left = rect.origin.x;
float x_left_center = x_left + cornerRadius;
float x_right_center = x_left + rect.size.width - cornerRadius;
float x_right = x_left + rect.size.width;
float y_top = rect.origin.y;
float y_top_center = y_top + cornerRadius;
float y_bottom_center = y_top + rect.size.height - cornerRadius;
float y_bottom = y_top + rect.size.height;
/* Begin path */
CGContextBeginPath(ctx);
CGContextMoveToPoint(ctx, x_left, y_top_center);
/* First corner */
CGContextAddArcToPoint(ctx, x_left, y_top, x_left_center, y_top, cornerRadius);
CGContextAddLineToPoint(ctx, x_right_center, y_top);
/* Second corner */
CGContextAddArcToPoint(ctx, x_right, y_top, x_right, y_top_center, cornerRadius);
CGContextAddLineToPoint(ctx, x_right, y_bottom_center);
/* Third corner */
CGContextAddArcToPoint(ctx, x_right, y_bottom, x_right_center, y_bottom, cornerRadius);
CGContextAddLineToPoint(ctx, x_left_center, y_bottom);
/* Fourth corner */
CGContextAddArcToPoint(ctx, x_left, y_bottom, x_left, y_bottom_center, cornerRadius);
CGContextAddLineToPoint(ctx, x_left, y_top_center);
/* Done */
CGContextClosePath(ctx);
}
}