예, 당신의 UIView를 사용하여이 작업을 수행 할 수 있습니다. 당신이 그런 그래픽 컨텍스트의 경로를 추가하고 당신이 원하는 색상을 것입니다 기입
UIBezierPath를 사용하여 원하는 경로를 만듭니다.
샘플 코드의 뜻은 다음과 같다 : 코드 위
#define kArrowHeight 50
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
UIBezierPath *fillPath = [UIBezierPath bezierPath];
[fillPath moveToPoint:CGPointMake(0, self.bounds.origin.y+kArrowHeight)];
[fillPath addLineToPoint:CGPointMake(self.bounds.size.width/2-(kArrowHeight/2), kArrowHeight)];
[fillPath addLineToPoint:CGPointMake(self.bounds.size.width/2, 0)];
[fillPath addLineToPoint:CGPointMake(self.bounds.size.width/2+(kArrowHeight/2), kArrowHeight)];
[fillPath addLineToPoint:CGPointMake(self.bounds.size.width, kArrowHeight)];
[fillPath addLineToPoint:CGPointMake(self.bounds.size.width, self.bounds.size.height)];
[fillPath addLineToPoint:CGPointMake(0, self.bounds.size.height)];
[fillPath closePath];
CGContextAddPath(context, fillPath.CGPath);
CGContextSetFillColorWithColor(context, [UIColor greenColor].CGColor);
CGContextFillPath(context);
}
는 당신에게 다음과 같은 팝 오버, 모양의 UIView의 중앙에 날카로운 모서리를 포함하는 뷰를 제공 할 것입니다.
는 참고 :
- 당신은 당신의 요구 사항에 따라 경로를 변경할 수 있습니다.
- 배경색은 깨끗한 색이어야합니다.
예를 들어 이미지를 제공하고 GitHub의에 타사 솔루션을 사용할 수없는 이유를 설명해주십시오. – Maarten
나는 이미지를 게시하는 데 충분한 명성을 얻지 못했다 .. – Venki
왜 내가 downvotes을 얻고 있는지 이해할 수 없다. 내 질문이 좋지 않다면 나에게 제안한다. 내 질문에 대해 downvote하지 마라. 고마워. – Venki