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 8293129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:43:31+00:00 2026-06-08T13:43:31+00:00

I am trying to achieve this glowing effect for a UILabel as shown below

  • 0

I am trying to achieve this glowing effect for a UILabel as shown below :

Glow effect

I have subclassed UILabel , and created a custom label class that adds an outer shadow.

Edit : Here’s the code i have used for outer shadow/glow in my custom Label class :

- (void)drawTextInRect:(CGRect)rect {
UIColor *insideColor;
UIColor *blurColor;
CGContextRef ctx = UIGraphicsGetCurrentContext();

insideColor =[UIColor colorWithRed:255/255.0 green:255/255.0 blue:191/255.0 alpha:1];
blurColor =[UIColor orangeColor];    


    CGContextSetFillColorWithColor(ctx, insideColor.CGColor);
    CGContextSetShadowWithColor(ctx, CGSizeMake(0, 0), self.glowAmount, blurColor.CGColor);
    CGContextSetTextDrawingMode(ctx, kCGTextFillStroke);

    [self.text drawInRect:self.bounds withFont:self.font lineBreakMode:self.lineBreakMode alignment:self.textAlignment];
}

But this gives me the following result

MyImage

As you can see this lacks the desired effect because of the missing inner shadow. Can anyone suggest how to achieve this?

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-08T13:43:34+00:00Added an answer on June 8, 2026 at 1:43 pm

    I referred the answer by Steven XM for Inner Shadow in UILabel . It was a great help.

    Here’s what i have done to achieve the result but i want to know if this can be more optimized?

    -(void)setInnerGlowWithColor:(UIColor *)shadowColor fillColor:(UIColor *)insideColor inRect:(CGRect)rect 
    {
    
        UIFont *font = self.font;
       // UIFont *font = [UIFont fontWithName:@"HelveticaNeue-Bold" size:17];
        CGSize fontSize = [self.text sizeWithFont:font];
    
    
        /****    Following are the steps to create an inside shadow ****/
    
        // STEP 1 :  Create a  image mask of your text.
    
            CGImageRef mask = [self createMaskWithSize:rect.size shape:^{
            [[UIColor blackColor] setFill];
            CGContextFillRect(UIGraphicsGetCurrentContext(), rect);
            [[UIColor whiteColor] setFill];
            // custom shape goes here
            [self.text drawAtPoint:CGPointMake((self.bounds.size.width/2)-(fontSize.width/2), 0) withFont:font];
            }];
    
    
        // STEP 2 : Invert that mask.
    
            CGImageRef cutoutRef = CGImageCreateWithMask([self blackSquareOfSize:rect.size].CGImage, mask);
            CGImageRelease(mask);
    
            UIImage *cutout = [UIImage imageWithCGImage:cutoutRef scale:[[UIScreen mainScreen] scale] orientation:UIImageOrientationUp];
            CGImageRelease(cutoutRef);  
    
    
    
         // STEP 3 : Use this inverted mask to draw a shadow around the inside edges of the text.
    
            CGImageRef shadedMask = [self createMaskWithSize:rect.size shape:^{
            [[UIColor whiteColor] setFill];
            CGContextFillRect(UIGraphicsGetCurrentContext(), rect);
            //****************For inner shadow/glow
            NSLog(@"in custom label---->  %f",self.glowAmount);
            CGContextSetShadowWithColor(UIGraphicsGetCurrentContext(), CGSizeMake(0, 0), self.glowAmount, shadowColor.CGColor);
            [cutout drawAtPoint:CGPointZero];
            }];
    
    
        // STEP 4 : Create negative image
    
            UIGraphicsBeginImageContextWithOptions(rect.size, NO, 0);
            [shadowColor setFill];
            // custom shape goes here
            [self.text drawAtPoint:CGPointMake((self.bounds.size.width/2)-(fontSize.width/2), 0) withFont:font];
            UIImage *negative = UIGraphicsGetImageFromCurrentImageContext();
            UIGraphicsEndImageContext(); 
    
    
        // STEP 5 : Create the shadow image
    
            CGImageRef innerShadowRef = CGImageCreateWithMask(negative.CGImage, shadedMask);
            CGImageRelease(shadedMask);
            UIImage *innerShadow = [UIImage imageWithCGImage:innerShadowRef scale:[[UIScreen mainScreen] scale] orientation:UIImageOrientationUp];
            CGImageRelease(innerShadowRef);
    
    
        // STEP 6 : Draw actual text
    
            [insideColor setFill];
            [self.text drawAtPoint:CGPointMake((self.bounds.size.width/2)-(fontSize.width/2), 0) withFont:font];  
    
    
        // STEP 7 : Finally apply the shadow image   
    
            [innerShadow drawAtPoint:CGPointZero];
    
    }
    
    
    - (UIImage*)blackSquareOfSize:(CGSize)size {
        UIGraphicsBeginImageContextWithOptions(size, NO, 0);  
        [[UIColor blackColor] setFill];
        CGContextFillRect(UIGraphicsGetCurrentContext(), CGRectMake(0, 0, size.width, size.height));
        UIImage *blackSquare = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
        return blackSquare;
    }
    
    
    - (CGImageRef)createMaskWithSize:(CGSize)size shape:(void (^)(void))block {
        UIGraphicsBeginImageContextWithOptions(size, NO, 0);  
        block();
        CGImageRef shape = [UIGraphicsGetImageFromCurrentImageContext() CGImage];
        UIGraphicsEndImageContext();  
        CGImageRef mask = CGImageMaskCreate(CGImageGetWidth(shape),
                                            CGImageGetHeight(shape),
                                            CGImageGetBitsPerComponent(shape),
                                            CGImageGetBitsPerPixel(shape),
                                            CGImageGetBytesPerRow(shape),
                                            CGImageGetDataProvider(shape), NULL, false);
        return mask;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to achieve this. I have session manager class, its something I
I have the following markup. <para><span class=bidi/><span class=ind/>1</para> I'm trying to achieve this... <para><span
I am trying to achieve this effect where a photo gets a repeating pattern
I am trying to achieve this using Expression Blend 3. I need that every
I am currently trying to achieve something like this: Based on this class, I
What I am trying to achieve is something like this: class object: def __init__(self):
I'm trying to achieve this effect with css3: The HTML code is cleanly something
I'm trying to achieve this mouseover effect with the smallest footprint possible. I can't
I'm basically trying to achieve this effect. It can be done with pretty much
This is what I'm trying to achieve: I want a UITextField that is in

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.