Drawing white overlay on UIImage

Discussion in 'iOS Development' started by gojohnnyboi, Mar 15, 2009.

  1. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55
    Okay, i've managed (after a 45 minute frustrating session of coregraphics) to draw a UIImage with rounded corners, at the size that i need it. However, i would like to know how i could go about making the image look like a springboard icon, with that white at the top.

    thx,
    john
  2. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    I'm on my phone, so I won't be verbose. Luckily for you, this is quite simple to do.

    1. Draw your base image into a CGContext with the size you want.
    2. Draw the second image, the one that contains the gloss into that same CGContext.
    3. Set the blend mode to kCGBlendModeOberlay.
    4. Clip the drawing into the rounded rect shape.
    5. Get the resulting CGImage and copy it into a new UIImage.
    6. Release the CGContext and all other variables, CG is very easy to leak.
  3. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55
    thanks man =]
  4. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    Hey, I don't know if you're interested, but I was recently handed a wondeful piece of code to draw beautiful Aqua like gradients. See the pseudo status bar in my most recent screenshots of PocketTouch. Sorry, but no link, I'm on my phone. And while Copy and Paste work fine, I hate waiting for the iPTF pages to load.

    I was going to post the code as a sample in the Tutorial subforum, but I still haven't received permission from the author (and it has been some time now). If you want the code, let me know, and I'll shoot you over a copy.
  5. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55

    Please Register or Log in to view images



    this? that's sexy, heh. i'll be on the irc tomorrow (i have much homework to do tonight), and i'll see if i can catch you there.

Share This Page