2

現在、小さな点の描画でグラフィカルな問題が発生しています。

ほとんどのプロフェッショナルなカレンダー アプリケーションでは、イベント カレンダーの識別子は小さな点であり、その色はイベント カレンダーの色です。

私は現在、より良い点を描く必要があるアプリケーションの時点にいます。ここに私が意味する写真があります。

カレンダー表セル

ここでは目立たないかもしれませんが、私の携帯電話では、色付きのドットはかなりピクセル化されています. ピクセル化を削除したいと思います。

Ray Wenderlich の Web サイト ( Ray Wenderlich Core Graphics ) のチュートリアルを実行しました。

ドットを描画するために私が得たものは次のとおりです。

UIGraphicsBeginImageContext(cell.imageViewPic.bounds.size);
CGContextRef contextRef = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(contextRef, [[event calendar] CGColor]);
CGContextFillEllipseInRect(contextRef,(CGRectMake (0.f, 0.f, cell.imageViewPic.bounds.size.width, cell.imageViewPic.bounds.size.height)));

UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
cell.imageViewPic.image = image;

したがって、これは実際に円を実装しますが、これを追加して円の周りに小さな線を描画し、ピクセレーションを取り除きましたが、うまくいきませんでした。

CGPoint startPoint = CGPointMake(cell.imageViewPic.frame.origin.x, cell.imageViewPic.frame.origin.y + cell.imageViewPic.frame.size.height - 1);
CGPoint endPoint = CGPointMake(cell.imageViewPic.frame.origin.x + cell.imageViewPic.frame.size.width - 1, cell.imageViewPic.frame.origin.y + cell.imageViewPic.frame.size.height - 1);
UIColor* color = [UIColor blackColor];
CGContextSaveGState(contextRef);
CGContextSetLineCap(contextRef, kCGLineCapSquare);
CGContextSetStrokeColorWithColor(contextRef, color.CGColor);
CGContextSetLineWidth(contextRef, 10.0);
CGContextMoveToPoint(contextRef, startPoint.x + 0.5, startPoint.y + 0.5);
CGContextAddLineToPoint(contextRef, endPoint.x + 0.5, endPoint.y + 0.5);
CGContextStrokePath(contextRef);
CGContextRestoreGState(contextRef);

まとめてこんな感じ…

UIGraphicsBeginImageContext(cell.imageViewPic.bounds.size);
CGContextRef contextRef = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(contextRef, [[event calendar] CGColor]);
CGContextFillEllipseInRect(contextRef,(CGRectMake (0.f, 0.f, cell.imageViewPic.bounds.size.width, cell.imageViewPic.bounds.size.height)));

CGPoint startPoint = CGPointMake(cell.imageViewPic.frame.origin.x, cell.imageViewPic.frame.origin.y + cell.imageViewPic.frame.size.height - 1);
CGPoint endPoint = CGPointMake(cell.imageViewPic.frame.origin.x + cell.imageViewPic.frame.size.width - 1, cell.imageViewPic.frame.origin.y + cell.imageViewPic.frame.size.height - 1);
UIColor* color = [UIColor blackColor];
CGContextSaveGState(contextRef);
CGContextSetLineCap(contextRef, kCGLineCapSquare);
CGContextSetStrokeColorWithColor(contextRef, color.CGColor);
CGContextSetLineWidth(contextRef, 10.0);
CGContextMoveToPoint(contextRef, startPoint.x + 0.5, startPoint.y + 0.5);
CGContextAddLineToPoint(contextRef, endPoint.x + 0.5, endPoint.y + 0.5);
CGContextStrokePath(contextRef);
CGContextRestoreGState(contextRef);

UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
cell.imageViewPic.image = image;

円はまだ描かれていますが、描かれている「ストローク」はありません。

このピクセレーションの問題がどのように解決されるかについて、誰かがいくつかの指針を与える場合は、投稿してください!

4

2 に答える 2

0

これは@Christian Di Lorenzoと同じ答えです..しかし、これはより簡単に短くなります。

これを変える:

UIGraphicsBeginImageContext(cell.imageViewPic.bounds.size);

これに:

UIGraphicsBeginImageContextWithOptions(cell.imageViewPic.bounds.size, NO, [UIScreen mainScreen].scale);

于 2015-11-18T12:26:14.933 に答える