views:

112

answers:

1

Hi,

i'm trying to immitate the count-label that is used in apples mail app, which shows the count of messages in a folder / mailbox. The text color is white, and the labels background is gray/blueish with rounded corners. (screenshot)

To get the same look, i made a custom UITableViewCell for my table, and tried to style the corresponding label like this:

label.layer.cornderRadius = 10.0;

This code basically looks like the mail app. However the performance of this code seems to be really poor. i've installed the app on my iphone 3gs, and when scrolling the table, the view is moving really slow and unsmooth. when i disable the rounded corners, its running great again. is my code somewhat wrong, or what can i do to improve performance? should i use png backgrounds rather than rounded corners? if so, what would i need to do to have the png background adjust its width according to the label width/text length? i already added code to do this and it works, but i think for png backgrounds it would just strech/distort the background image, right?

A: 

It sounds like using cornerRadius may force CALayer to do clipping, which is expensive. You can also "can" the shape as a stretchable image (which could be used as a background image on a UIView descendant) or draw it using CGPaths or UIBezierPaths.

Jesper