Search code examples
iosobjective-cios6uiviewuilabel

Trying to give UILabel a shadow, but it won't show up


I'm trying to give a label in one of the classes in my app a drop shadow, but it's not working at all. Nothing shows up. What am I doing wrong?

// Set label properties
titleLabel.font = [UIFont boldSystemFontOfSize:TITLE_FONT_SIZE];
titleLabel.adjustsFontSizeToFitWidth = NO;
titleLabel.opaque = YES;
titleLabel.backgroundColor = [UIColor clearColor];
titleLabel.textColor = titleLabelColor;
titleLabel.shadowColor = [UIColor blackColor];
titleLabel.shadowOffset = CGSizeMake(10, 10);

It's just white, no shadow.


Solution

  • Just Add this line to before adding titleLabel to self.view

     titleLabel.layer.masksToBounds = NO;
    

    Good Luck !!