UIEdgeInsets ignored on CGContextDrawImage within a UIGraphicsBeginImageContextWithOptions

后端 未结 1 514
半阙折子戏
半阙折子戏 2021-01-14 00:42

I am struggling getting Image Insets to work when drawing to an off screen buffer.

Using the resizableImageWithCapInsets: on an UIImage directly setImage: into a but

相关标签:
1条回答
  • 2021-01-14 01:34

    I would guess that stretchable UIImages are handled at a higher level than Quartz2D and so using CGContextDrawImage is not going to work.

    You could try using -[UIImage drawInRect] instead. This will draw to the current UIGraphics context, which is your bitmap context that you create in your code snippet.

    The relevant line is:

    [base drawInRect:CGRectMake(0,0,self.bounds.size.width,
                                        self.bounds.size.height)];
    
    0 讨论(0)
提交回复
热议问题