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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T00:32:39+00:00 2026-05-12T00:32:39+00:00

How can I create a person photo button like the one in contact info

  • 0

How can I create a “person photo” button like the one in contact info or in the Facebook app? (grey and rounded border with a small radius and an image that is cropped inside it)

Edit:

It must obviously work for all photos, not just one that I prerender in Photoshop.

I guess I could do it manually using masks etc., but Facebook app does it exactly like the contacts app, so I suspect there is some way to do it in the SDK.

  • 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-05-12T00:32:39+00:00Added an answer on May 12, 2026 at 12:32 am

    Here you (I :P) go:

    + (UIImage *)imageWithBorderForImage:(UIImage *)image
    {
        CGFloat radius = 5;
        CGSize size = image.size;
    
        radius = MIN(radius, .5 * MIN(size.width, size.height));
        CGRect interiorRect = CGRectInset(CGRectMake(0, 0, size.width, size.height), radius, radius);
    
        UIGraphicsBeginImageContext(size);
        CGContextRef context = UIGraphicsGetCurrentContext();
        CGContextSaveGState(context);
    
        CGMutablePathRef borderPath = CGPathCreateMutable();
        CGPathAddArc(borderPath, NULL, CGRectGetMinX(interiorRect), CGRectGetMinY(interiorRect), radius, 1.0*M_PI, 1.5*M_PI, NO);
        CGPathAddArc(borderPath, NULL, CGRectGetMaxX(interiorRect), CGRectGetMinY(interiorRect), radius, 1.5*M_PI, 0.0*M_PI, NO);
        CGPathAddArc(borderPath, NULL, CGRectGetMaxX(interiorRect), CGRectGetMaxY(interiorRect), radius, 0.0*M_PI, 0.5*M_PI, NO);
        CGPathAddArc(borderPath, NULL, CGRectGetMinX(interiorRect), CGRectGetMaxY(interiorRect), radius, 0.5*M_PI, 1.0*M_PI, NO);
    
        CGContextBeginPath(context);
        CGContextAddPath(context, borderPath);
        CGContextClosePath(context);
        CGContextClip(context);
    
        [image drawAtPoint:CGPointMake(0,0)];
    
        CGContextBeginPath(context);
        CGContextAddPath(context, borderPath);
        CGContextClosePath(context);
    
        CGContextSetRGBStrokeColor(context, 0.5, 0.5, 0.5, 1.0);
        CGContextSetLineWidth(context, 1.0);
        CGContextStrokePath(context);
    
        CGPathRelease(borderPath);
    
        UIImage *borderedImage = UIGraphicsGetImageFromCurrentImageContext();
        CGContextRestoreGState(context);
        UIGraphicsEndImageContext();
    
        return borderedImage;
    }
    

    Based largely on this question.

    One problem is that the border is actually 2px wide (although 1px falls outside of the clip area) because of anti-aliasing. Ideally the border would have ~0.5 alpha, but since the antialiasing gives each of the 2 pixels some alpha, I set it to 1 and it comes out just about right. If I disable antialiasing, then the corners aren’t rounded all the same :/

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

Sidebar

Related Questions

How can create a view with mutiple images, something similiar to the photo app
In my application I have classes/nodes like: -person -activity -company I can create relationships
If I create a PolyModel class, such as Person, can I create an Expando
I try to create a form that can save a person's form data so
I can create database manually by going to cpanel. But I'd like to create
I can create a contact that is not mail enabled, but how do I
One can create an anonymous object that is initialized through constructor parameters, such as
I have a form where users create Person records. Each Person can have several
When writing unit tests, there are cases where one can create an Assert for
I have a view scoped bean where I create a person. A person can

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.