CGContext
을 사용하여 깔때기 모양을 만들고 있는데, 먼저 삼각형을 그리고 그 다음에 선을 그립니다. 내 UIView
하위 클래스의 drawRect
에서 구현하고 있지만, 선이 약간 흐려 있기 때문에이 방법을 그리는 다른 방법이 있는지 궁금합니다. CGContext에 대한 더 나은 대안이 있습니까?
내가 디자인 이미지를 가져올 때 이미지가 선명 (당신이 아이폰에 알 수 있습니다)입니다 :
override func drawRect(rect: CGRect) {
let context: CGContextRef = UIGraphicsGetCurrentContext()!
CGContextClearRect(context, rect);
let rectWidth: CGFloat = 15
// Line
CGContextSetRGBStrokeColor(context, 0, 0, 0, 1)
CGContextMoveToPoint(context, rectWidth/2, 5)
CGContextAddLineToPoint(context, rectWidth/2, 10)
CGContextSetStrokeColorWithColor(context, UIColor.blueColor().CGColor)
CGContextSetLineCap(context, CGLineCap.Round)
CGContextSetLineWidth(context, 3.0)
CGContextStrokePath(context)
// Triangle
CGContextBeginPath(context);
CGContextMoveToPoint (context, CGRectGetMinX(rect), CGRectGetMinY(rect));
CGContextAddLineToPoint(context, CGRectGetMidX(rect), 8);
CGContextAddLineToPoint(context, CGRectGetMaxX(rect), CGRectGetMinY(rect));
CGContextClosePath(context);
UIColor.blueColor().setFill()
CGContextFillPath(context);
}
을,이다 거기 이 출력을 얻는 더 좋은 방법은? CGContext
라인은 약간 흐릿하므로 더 나은 대안이 있는지, 그리고 그러한 방법에 대한 찬반 양론이 무엇인지 알고 싶습니다.
두 이미지가 모두 흐릿하게 보입니다. – Tricertops