Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7831885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:55:49+00:00 2026-06-02T11:55:49+00:00

I have been trying every single method I found but I wasn’t able to

  • 0

I have been trying every single method I found but I wasn’t able to make it. I simply want to make a label with rounded corners, a drop shadow with a background pattern. The shadow works only if I do not want rounded corners. I can’t get them both together!

Here is my code with the shadow:

label.text = msg;
label.textAlignment = UITextAlignmentCenter;
label.frame = CGRectMake(20,10,280,40);
label.backgroundColor 
    = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"msg_box_bg.png"]];

[label.layer setCornerRadius:10];
[label.layer setMasksToBounds:NO];

/* Shadow */
label.layer.shadowColor = [UIColor blackColor].CGColor;
label.layer.shadowOpacity = 0.6;
label.layer.shadowOffset = CGSizeMake(0,0);
label.layer.shadowRadius = 3;

This gives me shadow without rounded corners. But if I use

[label.layer setMasksToBounds:YES];

This will give me rounded corners with no shadow. I have taken the advise to use a shadow path, so the code with the shadow path looks like this:

label.text = msg;
label.textAlignment = UITextAlignmentCenter;
label.frame = CGRectMake(20,10,280,40);
label.backgroundColor 
    = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"msg_box_bg.png"]];

[label.layer setCornerRadius:10];
[label.layer setMasksToBounds:YES];

/* Shadow */
label.layer.shadowColor = [UIColor blackColor].CGColor;
label.layer.shadowOpacity = 0.6;
label.layer.shadowOffset = CGSizeMake(0,0);
label.layer.shadowRadius = 3;
label.layer.shadowPath = [[UIBezierPath bezierPathWithRoundedRect:label.frame cornerRadius:10]CGPath];
label.layer.shouldRasterize = YES;

This code does give me rounded corners but no shadow.
Any suggestions?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T11:55:50+00:00Added an answer on June 2, 2026 at 11:55 am

    enter image description here

    I used the code below to get the results you were after.

    CGSize size = CGSizeMake(280, 40);
    
    /** Shadow */
    CALayer *shadowLayer = [CALayer new];
    shadowLayer.frame = CGRectMake(20,100,size.width,size.height);
    shadowLayer.cornerRadius = 10;
    
    shadowLayer.backgroundColor = [UIColor clearColor].CGColor; 
    shadowLayer.shadowColor = [UIColor blackColor].CGColor;
    shadowLayer.shadowOpacity = 0.6;
    shadowLayer.shadowOffset = CGSizeMake(0,0);
    shadowLayer.shadowRadius = 3;
    
    /** Label */
    UILabel *label = [UILabel new];
    label.text = @"Hello World";
    label.textAlignment = UITextAlignmentCenter;
    label.frame = CGRectMake(0, 0, size.width, size.height);
    label.backgroundColor = [UIColor clearColor]; 
    label.layer.cornerRadius = 10;
    [label.layer setMasksToBounds:YES];
    //  customLabel.backgroundColor = [UIColor whiteColor]; 
    label.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"options.png"]];
    
    /** Add the Label to the shawdow layer */
    [shadowLayer addSublayer:label.layer];
    
    [self.view.layer addSublayer:shadowLayer];      
    
    [shadowLayer release];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been trying to find a good jquery auto grow plugin but every single
I have been trying to add a click listener to every single marker on
I have been trying to make a div fade in evey 30sec and out
Have have been trying to make a validator for my xml files. I have
I have been trying to understand the way ActionScript's events are implemented, but I'm
I'm new to the MVC pattern but have been trying to grasp it, for
Ok I have been trying every which way to figure this out. I need
I have been trying to read a node from YouTube respons. If ever delt
I have been trying very hard to achieve rounded corners with IE6+jquery ui tabs.
I have been trying to us CALayers as sprites in an iPhone application I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.