Graphics Reference
In-Depth Information
LISTING 12-1
Continued
descriptionLabel = [[UILabel alloc] initWithFrame:CGRectZero];
[ descriptionLabel setNumberOfLines:0];
[ descriptionLabel setFont:[UIFont systemFontOfSize:6.0f]];
[ descriptionLabel setBackgroundColor:[UIColor clearColor]];
[contentView addSubview: descriptionLabel ];
[ descriptionLabel release];
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector ( imageUpdated :)
name: kImageDownloadComplete
object: nil ];
return self ;
}
As you can see, the UILabel objects, titleLabel and descriptionLabel , both have their
-backgroundColor set to [UIColor clearColor] , causing an alpha blending to occur. To
correct this, change that UIColor to be the same color as the background for the entire
UITableViewCell . This eliminates the alpha blending and improves performance, as
shown in Listing 12-2.
LISTING 12-2
Corrected [CustomTableViewCell -initWithFrame:reuseIdentifier:]
- ( id )initWithFrame:(CGRect)frame reuseIdentifier:(NSString*)ident
{
if (!( self = [ super initWithFrame :frame reuseIdentifier :ident])) return nil ;
UIView *contentView = [ self contentView];
imageView = [[UIImageView alloc] initWithFrame:CGRectMake(5, 5, 64, 64)];
[ imageView setContentMode:UIViewContentModeScaleAspectFit];
[contentView addSubview: imageView ];
[ imageView release];
titleLabel = [[UILabel alloc] initWithFrame:CGRectZero];
[ titleLabel setFont:[UIFont boldSystemFontOfSize:14.0f]];
[ titleLabel setBackgroundColor:[UIColor whiteColor]];
[contentView addSubview: titleLabel ];
[ titleLabel release];
 
Search WWH ::




Custom Search