Note that there are some explanatory texts on larger screens.

plurals
  1. POUIBezierPath curve from far edges
    primarykey
    data
    text
    <p>In iOS i'm trying to draw a clipped image. I want the clipping to be from one edge, curved to the farthest opposite edge. The below image illustrates in red, the border of the final image. In this example the curve goes from bottom left to top right.</p> <p><img src="https://i.stack.imgur.com/e1ddA.png" alt="enter image description here"></p> <p>Here is the code I currently wrote. My only problem is this method <code>bezierPathWithRoundedRect:byRoundingCorners:cornerRadii:</code> does not curve to the extend i need.</p> <pre><code>- (UIImage *)roundCorneredImage:(UIImage *)image radius:(CGFloat)radius { CGRect imageRect = CGRectZero; imageRect.size = image.size; UIGraphicsBeginImageContextWithOptions(imageRect.size, NO, [UIScreen mainScreen].scale); CGSize size = CGSizeMake(radius, radius); [[UIBezierPath bezierPathWithRoundedRect:imageRect byRoundingCorners:UIRectCornerBottomRight cornerRadii:size] addClip]; [image drawInRect:imageRect]; UIImage* result = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return result; } </code></pre> <p>UPDATE:</p> <p>Heres the result I'm getting and my updated code. I need some further assistance... </p> <p><img src="https://i.stack.imgur.com/fYRXm.png" alt="enter image description here"></p> <pre><code>UIBezierPath* bezier = [UIBezierPath bezierPath]; [bezier moveToPoint:CGPointMake(0, 0)]; [bezier addLineToPoint:CGPointMake(0, imageRect.size.height)]; [bezier addArcWithCenter:CGPointMake(imageRect.size.width / 2, imageRect.size.height / 2) radius:imageRect.size.height / 2 startAngle:M_PI / 2 endAngle:0 clockwise:NO]; [bezier addLineToPoint:CGPointMake(0, 0)]; [bezier addClip]; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload