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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:18:08+00:00 2026-06-11T00:18:08+00:00

How can I draw highlights and non-4-sided borders natively in Cocoa? An example is

  • 0

How can I draw highlights and non-4-sided borders natively in Cocoa?

An example is the image below. There’s a small 1px white inner border on the top and a grey 1px inner border on the bottom. There’s also a dark gray border only on the top and the bottom of the view.

Can this be done natively? Or does this require images?

enter image description here

  • 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-11T00:18:10+00:00Added an answer on June 11, 2026 at 12:18 am

    A quick way to get an inner border is to use the layer’s shadow properties from the view you want bordered (note the -1, which places the border inside the edge):

    myView.layer.shadowOpacity = 1.0;
    myView.layer.shadowColor = [UIColor blackColor].CGColor;
    myView.layer.shadowOffset = CGSizeMake( 0, -1 );
    

    Otherwise you can subclass the view and put something like this in your drawRect: method:

    [super drawRect: rect];
    
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSaveGState( context );
    CGContextSetStrokeColorWithColor( context, [UIColor blackColor].CGColor );
    CGContextSetLineWidth( context,  1.0 );
    
    CGContextMoveToPoint( context, 0, 0 );
    
    CGContextAddLineToPoint( context,  self.bounds.size.width, 0 );
    CGContextStrokePath( context );        
    
    CGContextRestoreGState( context );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can i draw text on canvas as shown in below image highlighted in
Is there a way i can draw the black background behind the image using
i can draw a string/image... with drawInRect/drawAtPoint. but how about if i want to
Any idea how I can draw Bullet Points using Flex? instead of using image
the pixman image library can draw radial color gradients between two circles. I'd like
There are any control who can draw a rule regardless of the screen resolution?
How I can draw a sine wave on canvas inside an Image View in
is there some UML tool where I can draw my database design and generate
Is there any tool where I can draw Entity Framework models and it generates
I can draw an image into the navbar by adding this to the bottom

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.