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

  • SEARCH
  • Home
  • 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 8576287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:53:32+00:00 2026-06-11T19:53:32+00:00

How to create a reflection of UIImage without using UIImageView ? I have seen

  • 0

How to create a reflection of UIImage without using UIImageView ? I have seen the apple code for reflection using two imageViews but i don’t want to add imageview in my application i just want whole image of the original image and the reflected image. Does any body knows how to do that.

  • 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-11T19:53:33+00:00Added an answer on June 11, 2026 at 7:53 pm

    This is from UIImage+FX.m, created by Nick Lockwood

    UIImage * processedImage = //here your image
    processedImage = [processedImage imageWithReflectionWithScale:0.15f
                                                                              gap:10.0f
                                                                            alpha:0.305f];
    

    Scale is the size of the reflection, gap the distance between the image and the reflection, and alpha the alpha of the reflection

    - (UIImage *)imageWithReflectionWithScale:(CGFloat)scale gap:(CGFloat)gap alpha:(CGFloat)alpha
    {
        //get reflected image
        UIImage *reflection = [self reflectedImageWithScale:scale];
        CGFloat reflectionOffset = reflection.size.height + gap;
    
        //create drawing context
        UIGraphicsBeginImageContextWithOptions(CGSizeMake(self.size.width, self.size.height + reflectionOffset * 2.0f), NO, 0.0f);
    
        //draw reflection
        [reflection drawAtPoint:CGPointMake(0.0f, reflectionOffset + self.size.height + gap) blendMode:kCGBlendModeNormal alpha:alpha];
    
        //draw image
        [self drawAtPoint:CGPointMake(0.0f, reflectionOffset)];
    
        //capture resultant image
        UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
    
        //return image
        return image;
    }
    

    and

    - (UIImage *)reflectedImageWithScale:(CGFloat)scale
    {
        //get reflection dimensions
        CGFloat height = ceil(self.size.height * scale);
        CGSize size = CGSizeMake(self.size.width, height);
        CGRect bounds = CGRectMake(0.0f, 0.0f, size.width, size.height);
    
        //create drawing context
        UIGraphicsBeginImageContextWithOptions(size, NO, 0.0f);
        CGContextRef context = UIGraphicsGetCurrentContext();
    
        //clip to gradient
        CGContextClipToMask(context, bounds, [[self class] gradientMask]);
    
        //draw reflected image
        CGContextScaleCTM(context, 1.0f, -1.0f);
        CGContextTranslateCTM(context, 0.0f, -self.size.height);
        [self drawInRect:CGRectMake(0.0f, 0.0f, self.size.width, self.size.height)];
    
        //capture resultant image
        UIImage *reflection = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
    
        //return reflection image
        return reflection;
    }
    

    gradientMask

    + (CGImageRef)gradientMask
    {
        static CGImageRef sharedMask = NULL;
        if (sharedMask == NULL)
        {
            //create gradient mask
            UIGraphicsBeginImageContextWithOptions(CGSizeMake(1, 256), YES, 0.0);
            CGContextRef gradientContext = UIGraphicsGetCurrentContext();
            CGFloat colors[] = {0.0, 1.0, 1.0, 1.0};
            CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceGray();
            CGGradientRef gradient = CGGradientCreateWithColorComponents(colorSpace, colors, NULL, 2);
            CGPoint gradientStartPoint = CGPointMake(0, 0);
            CGPoint gradientEndPoint = CGPointMake(0, 256);
            CGContextDrawLinearGradient(gradientContext, gradient, gradientStartPoint,
                                        gradientEndPoint, kCGGradientDrawsAfterEndLocation);
            sharedMask = CGBitmapContextCreateImage(gradientContext);
            CGGradientRelease(gradient);
            CGColorSpaceRelease(colorSpace);
            UIGraphicsEndImageContext();
        }
        return sharedMask;
    }
    

    it returns the image with the reflection.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a Comparison<>-Delegate via reflection in code. I have this: var
I am using the following code to create a dynamic reflection of an image:
I have seen Attributes and Reflection and now i know how to create and
I am using System.Reflection.Emit, and at some point I want to create a delegate
Experimenting using different approaches and reducing code maintenance I have ended up using reflection
There are plenty of threads on how to create a Method using Reflection.Emit but
I'm trying to create a textview with reflection on android but I could not
I am trying to create instance of class by using reflection in ASP.net web
Does C# offer a way to create Enum type from scratch using reflection? Suppose,
Can anyone tell me how I would create a MustOverride property using Reflection?

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.