2
맨 위에 작은 캐럿 화살표가있는 둥근 사각형을 그리는 다음 코드가 있습니다. 나는 위와 왼쪽, 오른쪽, 또는 아래쪽에 내가 지정한 것에 따라 화살표를 그리는 메소드를 생성 할 수 있기를 원한다. (아마도 enum typedef를 전달할 것이다).이 UIBezierPath의 화살표 방향을 변경하는 방법
이사람이 날이 코드를 더 동적으로 만들 도와 드릴까요/유연한 그래서 나는이 작업을 수행 할 수 있습니다 : 여기
내 코드는 지금 생성 무엇인가?
CGContextBeginPath(context);
CGContextMoveToPoint(context, kBubbleBorderRadius + 0.5f, kCaretHeight + 0.5f);
CGContextAddLineToPoint(context, round(currentFrame.size.width/2.0f - (kCaretHeight * 2.0)/2.0f) + 0.5f, kCaretHeight + 0.5f);
CGContextAddLineToPoint(context, round(currentFrame.size.width/2.0f) + 0.5f, 0.5f);
CGContextAddLineToPoint(context, round(currentFrame.size.width/2.0f + (kCaretHeight * 2.0)/2.0f) + 0.5f, kCaretHeight + 0.5f);
CGContextAddArcToPoint(context, currentFrame.size.width - 0.5f, kCaretHeight + 0.5f, currentFrame.size.width- 0.5f, currentFrame.size.height - 0.5f, kBubbleBorderRadius);
CGContextAddArcToPoint(context, currentFrame.size.width - 0.5f, currentFrame.size.height - 0.5f, round(currentFrame.size.width/2.0f + (kCaretHeight * 2.0)/2.0f) + 0.5f, currentFrame.size.height - 0.5f, kBubbleBorderRadius);
CGContextAddArcToPoint(context, 0.5f, currentFrame.size.height - 0.5f, 0.5f, kCaretHeight + 0.5f, kBubbleBorderRadius);
CGContextAddArcToPoint(context, 0.5f, kCaretHeight + 0.5f, currentFrame.size.width - 0.5f, kCaretHeight + 0.5f, kBubbleBorderRadius);
CGContextClosePath(context);
CGContextDrawPath(context, kCGPathFill);
원하는 그래픽 표현을 제공 할 수 있습니까? – Injectios
@Injectios는 현재 코드 생성에 대한 이미지를 추가하여 감사합니다. –
몸체와 별도로 삼각형을 그리면 더 쉽습니다. – thelaws