2

MKAnnotation に塗りつぶしを適用しようとしています。ほとんど機能するコードを見つけましたが、塗りつぶしを適用した後、何らかの理由で塗りつぶされた画像が上下逆になります。

マップピンで実行している現在のコードは次のとおりです。

CGRect rect = CGRectMake(0, 0, self.image.size.width, self.image.size.height);
    UIGraphicsBeginImageContext(self.image.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextClipToMask(context, rect, self.image.CGImage);
    CGContextSetFillColorWithColor(context, [[UIColor grayColor] CGColor]);
    CGContextFillRect(context, rect);
    CGContextRotateCTM(context, 90);
    UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    UIImage *flippedImage = [UIImage imageWithCGImage:img.CGImage
                                                scale:1.0 orientation:self.image.imageOrientation];

    self.image = flippedImage;

このコードを実行した後のピンは次のようになります。

http://d.pr/i/UaPU

現在の画像の向きを FlippedImage に適用するとうまくいくと思っていましたが、うまくいきませんでした。self.image = img;また、flippedImage 変数を完全に設定および削除しようとしましたが、結果は同じです。

4

1 に答える 1