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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:27:10+00:00 2026-06-16T02:27:10+00:00

Aight so I want to draw a triangle like so: Currently I’m using a

  • 0

Aight so I want to draw a triangle like so:

rounded triangle

Currently I’m using a combination of a CAShapeLayer and creating the path with a UIBezierPath (the code is below) and then applying that as a mask for another layer (self.layer as I’m in a UIView subclass and rather than setting layerclass I’m doing it this way so I can preserve the initial layer)

anyways the code:

_bezierPath = [[UIBezierPath bezierPath] retain];
#define COS30 0.86602540378
#define SIN30 0.5
[_bezierPath moveToPoint:(CGPoint){self.frame.size.width/2.f-r*SIN30,r*COS30}];
[_bezierPath addArcWithCenter:(CGPoint){self.frame.size.width/2.f,r*COS30*2.f} radius:r startAngle:2*M_PI/3.f endAngle:M_PI/3.f clockwise:YES];
[_bezierPath addLineToPoint:(CGPoint){self.frame.size.width-r*SIN30,self.frame.size.height-r*COS30}];
[_bezierPath addArcWithCenter:(CGPoint){self.frame.size.width-r*SIN30-r,self.frame.size.height-r*COS30} radius:r startAngle:0.f endAngle:-M_PI/3.f clockwise:YES];
[_bezierPath addLineToPoint:(CGPoint){r*SIN30,self.frame.size.height-r*COS30}];
[_bezierPath addArcWithCenter:(CGPoint){r*SIN30+r,self.frame.size.height-r*COS30} radius:r startAngle:4*M_PI/3.f endAngle:M_PI clockwise:YES];
[_bezierPath closePath];
CAShapeLayer *s = [CAShapeLayer layer];
s.frame = self.bounds;
s.path = _bezierPath.CGPath;
self.layer.mask = s;
self.layer.backgroundColor = [SLInsetButton backgroundColorForVariant:SLInsetButtonColorForSLGamePieceColor(_color)].CGColor;

and unfortunately the result is not what I was looking for, instead the corners become little knobs (as if its turning too much)

Thanks in advance

  • 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-16T02:27:11+00:00Added an answer on June 16, 2026 at 2:27 am

    A brilliant friend (John Heaton in case you run into him, he’s pretty awesome) reminded me of the lineCap and lineJoin properties that core graphics deploys.

    Somewhere:

    #define border (10.f)
    

    And in your interface:

    @property (nonatomic, strong) UIBezierPath *bezierPath;
    

    And in your init, create a short path like this:

    CGFloat inset = border / 2.f;
    UIBezierPath *bezierPath = [UIBezierPath bezierPath];
    [bezierPath moveToPoint:(CGPoint){ self.frame.size.width/2.f, inset }];
    [bezierPath addLineToPoint:(CGPoint){ self.frame.size.width - inset, self.frame.size.height - inset }];
    [bezierPath addLineToPoint:(CGPoint){ a, self.frame.size.height - a }];
    [bezierPath closePath];
    
    self.bezierPath = bezierPath;
    

    And then in your drawRect: method do something like the following:

    CGContextRef c = UIGraphicsGetCurrentContext(), context = c;
    CGColorRef col = [UIColor redColor].CGColor;
    CGColorRef bcol = [UIColor redColor].CGColor;
    CGContextSetFillColorWithColor(c, col);
    CGContextSetStrokeColorWithColor(c, bcol);
    CGContextSetLineWidth(c, border);
    CGContextSetLineJoin(c, kCGLineJoinRound);
    CGContextSetLineCap(c, kCGLineCapRound);
    CGContextAddPath(c, self.bezierPath.CGPath);
    CGContextStrokePath(c);
    CGContextAddPath(c, self.bezierPath.CGPath);
    CGContextFillPath(c);
    

    And that will properly give you rounded corners on a triangle, also with the option to have a border or outline

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

Sidebar

Related Questions

Here is my code: Sorry for the quality and formatting. Basically, what i want
Aight, did a bit of Googling and searching here, the only question I found
I have a simple piece of code, that compiles in Delphi XE2 but not
I am wondering if someone can tweak my code to get the functionality I
is it possible to add 2 cell.textlabel into the table view. As i want
For example: Hello! :) It's a good day to-day :D 'Aight? <3 It would
Friends please help me to parse this response using Json object and json array
New to objective c. I am using NSArray to populate my UITableView . is
When using strings as keys of an array, console is showing that the array
I have an idea for a layout I would like to use, but I

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.