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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:32:47+00:00 2026-06-15T10:32:47+00:00

How do I add dashed line border around UIView . Something Like this

  • 0

How do I add dashed line border around UIView.

Something Like this

  • 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-15T10:32:49+00:00Added an answer on June 15, 2026 at 10:32 am

    You can set the border with this pattern using Layer and Bezier path like below examples.

    Objective-C

    CAShapeLayer *yourViewBorder = [CAShapeLayer layer];
    yourViewBorder.strokeColor = [UIColor blackColor].CGColor;
    yourViewBorder.fillColor = nil;
    yourViewBorder.lineDashPattern = @[@2, @2];
    yourViewBorder.frame = yourView.bounds;
    yourViewBorder.path = [UIBezierPath bezierPathWithRect:yourView.bounds].CGPath;
    [yourView.layer addSublayer:yourViewBorder];
    

    Swift 3.1

    var yourViewBorder = CAShapeLayer()
    yourViewBorder.strokeColor = UIColor.black.cgColor
    yourViewBorder.lineDashPattern = [2, 2]
    yourViewBorder.frame = yourView.bounds
    yourViewBorder.fillColor = nil
    yourViewBorder.path = UIBezierPath(rect: yourView.bounds).cgPath
    yourView.layer.addSublayer(yourViewBorder)
    

    You can also set different types of design using pattern image like below example.

    [yourView.layer setBorderWidth:5.0];
    [yourView.layer setBorderColor:[[UIColor colorWithPatternImage:[UIImage imageNamed:@"DotedImage.png"]] CGColor]];///just add image name and create image with dashed or doted drawing and add here
    

    Here you’ve to add <QuartzCore/QuartzCore> framework in the project and import it with below line in YourViewController.m file.

    #import <QuartzCore/QuartzCore.h>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a RadioGroup I would like to add a dashed stroke(boder?) with some
function Add(a, b) { } If we call a javascript function like - onclick=Add(1)
I add this problem for quite some time when using NetBeans. Recently I add
I have found several articles on the Web regarding drawing a dashed line in
I am having problems with this thing: can I, in some way, add a
I'd like to add Unicode characters to plain text email being sent via SMTP.
I have this as my date: 1212009 so this should be like 12/1/2009 but
I have a list that I want to add a border to it. but
I created a 200x200 square div and created a dashed border to define it.
How would you add a line separating definition groups in a definition list, with

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.