views:

25

answers:

1

I'm having a problem I most definitely don't understand. I have the following subclass of UIView:

 @implementation TimelineSystemEventView

 - (id)initWithFrame:(CGRect)frame {
     if ((self = [super initWithFrame:frame])) {
    CGRect newFr = CGRectMake(-30, 0, 60, 25);
    label = [[UILabel alloc] initWithFrame:newFr];
    [self addSubview:label];
    label.textAlignment = UITextAlignmentCenter;
    label.backgroundColor = [UIColor whiteColor];
    label.font = [UIFont boldSystemFontOfSize:10];
    label.alpha = 1;
    }
    return self;
 }

- (void)dealloc {
    self.label = nil;
    [super dealloc];
}

@synthesize label;


@end

The significant part is the UILabel I have added (it is an instance variable, so we're clear)

I'll mention that I changed the alpha of this UIView, my subclass, but regardless of the value of alpha, my UILabel doesn't have a completely white background. I can see the superview showing through.

The superview is a thin black strip, and when I add the UILabel, the black strip becomes a lighter color, as though the label is partially transparent. I want the label to completely cover the superview, and I thought this would happen by setting the background color to white and the alpha to 1.

Can you help me understand what's going on here and what I can do to fix it?

Thanks for any help.

A: 

I think you want to set the UILable backgroundColor to [UIColor clearColor], you don't need to set the alpha value.

catlan
No not really, I want the UILabel to be opaque, cover the view behind it completely. clearColor would be the opposite of what I want.
Alex Gosselin