For some reason, this code in a custom UIView is giving me two of the same label on the screen.
Code:
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self)
{
currentTool = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 330.0, 320.0, 40.0)];
currentTool.text = @"No tool selected.";
currentTool.textAlignment = UITextAlignmentCenter;
currentTool.textColor = [UIColor blackColor];
currentTool.shadowColor = [UIColor grayColor];
currentTool.shadowOffset = CGSizeMake(1.0, 1.0);
currentTool.backgroundColor = [UIColor clearColor];
[self addSubview:currentTool];
}
return self;
}
This view is a subview of another view, so could it be adding the label to the other view too? It would match up, because this view's frame is slightly smaller than the other view, so there would be an offset. Any other ideas why this is happening?