Is there a way to set cornerRadius
for only top-left and top-right corner of a UIView
?
I tried the following, but it end up not seeing the
Emma: .TopRight
and .BottomRight
are not working for you perhaps because the call to view.roundCorners
is done BEFORE final view bounds
are calculated. Note that the Bezier Path
derives from the view bounds at the time it is called. For example, if auto layout will narrow the view, the round corners on the right side might be outside the view.
Try to call it in viewDidLayoutSubviews
, where the view's bound is final.
This is how you can set a corner radius for each corner of a button with Xamarin in C#:
var maskPath = UIBezierPath.FromRoundedRect(MyButton.Bounds, UIRectCorner.BottomLeft | UIRectCorner.BottomRight,
new CGSize(10.0, 10.0));
var maskLayer = new CAShapeLayer
{
Frame = MyButton.Bounds,
Path = maskPath.CGPath
};
MyButton.Layer.Mask = maskLayer;