CALayer Poor Performance

Discussion in 'iOS Development' started by cocotutch, Jul 29, 2010.

  1. cocotutch

    cocotutch Community Development Team Staff Member

    Joined:
    Oct 6, 2008
    Messages:
    1,285
    Likes Received:
    117
    Device:
    5G iPod touch
    Hi there, it's been a long time since I've posted here.

    [OBJC]embed.layer.shadowOffset = CGSizeMake(0,5);
    embed.layer.shadowColor = [UIColor blackColor].CGColor;
    embed.layer.shadowOpacity = 0.8;
    embed.layer.shadowRadius = 4;
    embed.layer.shouldRasterize = YES;
    [embed setNeedsDisplay];[/OBJC]

    The above code runs fine on the Simulator, of course it would. But on my iPhone 3G...(BEFORE you say it, I'm getting an iPhone 4 next year, I need an upgrade)...everything is sluggish. the app still functions but barely. I have several UIView Animations that activate, and their framerate is like reduced to 0.5fps. Is there a way I can get the drop shadow to speed up and function normally? A drop shadow on my View is CRUCIAL to my new app, so there needs to be a way. Would CG be a better option?

    Thanks.

    coco
  2. NolesFans

    NolesFans New Member

    Joined:
    Sep 23, 2008
    Messages:
    404
    Likes Received:
    0
    Device:
    iPod touch
    The simulator is always faster than device, this is not news. CG is supposed to run in the GPU, Skylar probably knows.
  3. bddckr

    bddckr Active Member

    Joined:
    Dec 2, 2007
    Messages:
    1,434
    Likes Received:
    18
    Device:
    iPhone 4 (Black)
  4. Steaps

    Steaps New Member

    Joined:
    Oct 24, 2007
    Messages:
    5,074
    Likes Received:
    41
    Device:
    iPod touch
    Anything with opacity will run slower than something without opacity. If this is an object, and you have a ton of instances of this, it will run slowly because of the opacity. Draw as flat as you can for best performance.

Share This Page