Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Just two rounded corners? [duplicate]

Tags:

In my iPad app, I want a second view to appear within the main when the user clicks a button. The new view will be smaller than the first, and darken the background when it is displayed. I want the top two corners of the new view to appear rounded, but using cornerRadius sets all of them rounded. How can I make just two corners rounded?

like image 804
Jumhyn Avatar asked Jan 30 '11 20:01

Jumhyn


People also ask

What is a rectangle with 2 rounded corners called?

Microsoft calls it a Round diagonal corner rectangle. Here are the names of various rectangles (one can confirm this for oneself by mouse-hovering over these shapes in e.g. Powerpoint or Word): Follow this answer to receive notifications. edited Sep 12, 2018 at 20:52.

What is a rounded corner called?

bevel. (redirected from Rounded corner)


1 Answers

In Objective C

   // Create the path (with only the top-left corner rounded)
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:imageView.bounds 
                          byRoundingCorners:UIRectCornerTopLeft| UIRectCornerTopRight
                          cornerRadii:CGSizeMake(10.0, 10.0)];
// Create the shape layer and set its path
CAShapeLayer *maskLayer = [CAShapeLayer layer];
maskLayer.frame = imageView.bounds;
maskLayer.path = maskPath.CGPath;
// Set the newly created shape layer as the mask for the image view's layer
imageView.layer.mask = maskLayer;

This is other to use top rounded corner. Round two corners in UIView

In Swift !!!

myView.clipsToBounds = true
myView.layer.cornerRadius = 10
myView.layer.maskedCorners = [.layerMinXMinYCorner,.layerMaxXMinYCorner]

enter image description here

like image 169
SachinVsSachin Avatar answered Oct 22 '22 00:10

SachinVsSachin