views:

53

answers:

0

Hey people,

i got a real performance issue on my app after adding a new class. this class extends UIButton. In the initWithFrame: method im setting some parameters like:

[self.layer setBorderColor:[[UIColor lightGrayColor] CGColor]];
[self.layer setCornerRadius:5.0];
[self.layer setBorderWidth:1.0];   

After that i add some gradient layers to let the button look nicer. Now i got the problem, that everytime this button is in a view the whole view is totally lagging. In some views i have a button grid of 10x10 and then its horrible lagging. I thought CGLayer and CoreGraphics are fast enough to display that amount of buttons. Even when i display just 2-3 of these buttons its getting noticeable slower. Shouldn't it be no problem to render 2-3 buttons without performing issues?

the basic problem behind this is, that i have in different views different sized buttons, but they all should look almost the same. that is why i use this button and drawing a border and a gradient in it. Is there a way to use Images instead of layer-properties? The problem here is that the height and width of each button could be different, so its not like storing one image and use this as a background, or?

I thought of making a pixel 1px width and stretch this. But how high should this image be, for a gradient looking always nice and good on different heights?

Is it possible to render the button with CGLayer and save this to an image and use this image as background for the button?

Do you have any ideas or tips how i can fix this performance problems or do you have an idea how to solve this with images?

BTW: i just figured out, if i use just the border-properties without the gradient its also laggy. i think i have a general problem of CGLayer performance.

Thanks for any advice on these different questions! :)

cheers phil