Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

moonman239

Cancelled
Original poster
Mar 27, 2009
1,541
32
When I place Alice over Bob, depending on Bob's text and location, I can see some of Bob's text, no matter how far into Alice's frame Bob's text is. Why?
 
Last edited:
Likely because the label background is clear. Play with the following code to see a sample. I've set the text color and border to help display highlight the result.

Code:
    CGRect lableRect = CGRectMake(20.0, 250.0, 50.0, 22.0);
    UILabel * bob = [[UILabel alloc] initWithFrame: lableRect];
    bob.layer.borderColor = [[UIColor redColor] CGColor];
    bob.textColor = [UIColor redColor];
    bob.layer.borderWidth = 1.0;
    bob.text = @"Bob";
    
    lableRect = CGRectMake(40.0, 250.0, 50.0, 22.0);
    UILabel * alice = [[UILabel alloc] initWithFrame: lableRect];
    alice.layer.borderColor = [[UIColor blueColor] CGColor];
    alice.layer.borderWidth = 1.0;
    alice.text = @"Alice";
    alice.textColor = [UIColor blueColor];
    alice.backgroundColor = [UIColor clearColor];
    
    [self.view addSubview: bob];
    [self.view addSubview: alice];
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.