I'm building a custom UIView, which draws its own content in a drawRect: Method. I want to stroke a CGPath with a color, and then grow this selection 1px and stroke with another color. Has somebody worked out a method to do this quite easily?
A:
You could try applying an appropriate scaling transformation to your graphics context.
Ole Begemann
2010-04-23 22:22:52
Thanks for answering, unfortunately, that's not doing it. What it actually does is scaling everything (I only want a copy of a CGPath to grow). I'm looking for functionality similar to what you'd find in Graphics Editing Programs.
FenderMostro
2010-04-23 23:19:25
That depends entirely on the order of your calls. If you draw the original path first, then apply the scaling transform, then draw the second path, then revert the transform, only the second path will be transformed. Note that you will probably also have to adjust the stroke width by `1/scaleFactor` to counteract the transform.
Ole Begemann
2010-04-23 23:30:17
Ok, got it now. I was calling them in the right order, except the path that I wanted to stroke was the same color as the background!!! Man, Friday is a killer. Thanks for all your help, I'll see if I can create a nice wrapper function to allow me to specify CGPath selection growth by a number of pixels. Cheers.
FenderMostro
2010-04-23 23:40:49