I'm struggling to get Image Insets to work when I draw to the clipboard without a screen.
Using resizableImageWithCapInsets: on UIImage directly setImage: the button works fine for me:
UIImage * base = [UIImage imageNamed:@"button.png"]; UIImage * img = [base resizableImageWithCapInsets:UIEdgeInsetsMake(20,20,20,20)]; [self setImage:img forState:UIControlStateNormal];
As shown below (on the left - raw scaling, on the right it scales using attachments):


So, the correct option is that the top / botton / left / right lines are equally distributed. So far so good.
Now, if I try to do the same with the image that will be drawn, and then written to the buffer without a screen:
UIImage * base = [UIImage imageNamed:@"button.png"]; base = [base resizableImageWithCapInsets:UIEdgeInsetsMake(20,20,20,20)]; UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, 0); ctx = UIGraphicsGetCurrentContext(); CGContextDrawImage(ctx, CGRectMake(0,0,self.bounds.size.width, self.bounds.size.height), [base CGImage]); img = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); [self setImage:img forState:UIControlStateNormal];
I get lower (again on the left - raw scaling, on the right - inserts):

.
So it seems that the inserts are being ignored.
Are there any suggestions as to what is going on here? A fully functional example at http://people.apache.org/~dirkx/insetSample.zip and only key code at http://pastebin.com/rm8h6YFV .
Any suggestions are welcome.
Dw