Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I determined a solution</p> <pre><code>// Flip the coordinates so that the object is drawn as if it were mirrored along the x-axis // coordinates = @[CGPointMake(1, 2), CGPointMake(9, 17), CGPointMake(41, 3), ...] NSArray *flippedCoordinates = [coordinates map:^id(id object) { CGPoint value; [object getValue:&amp;value]; CGPoint point = value; point.y = point.y * (-1) + rect.size.height; return [NSValue value:&amp;point withObjCType:@encode(CGPoint)]; }]; // Generate a CGPathRef using the new coordinates CGMutablePathRef pathRef = CGPathCreateMutable(); CGPathMoveToPoint(pathRef, NULL, [[flippedCoordinates objectAtIndex:0] CGPointValue].x + .5 [[flippedCoordinates objectAtIndex:0] CGPointValue].y + .5); for(NSValue *arrayValue in flippedCoordinates) { CGPoint point = [arrayValue CGPointValue]; CGPathAddLineToPoint(pathRef, NULL, point.x, point.y); } CGPathCloseSubpath(pathRef); // Draw the object // ... // Draw the text as if it were on OS X CGContextSetTextMatrix(context, CGAffineTransformIdentity); NSAttributedString* attString = [[NSAttributedString alloc] initWithString:@"0,1,2,..." attributes:@{(NSString *)kCTForegroundColorAttributeName : textColor}]; CTFramesetterRef frameSetter = CTFramesetterCreateWithAttributedString((__bridge CFAttributedStringRef)attString); CTFrameRef frame = CTFramesetterCreateFrame(frameSetter, CFRangeMake(0, [attString length]), pathRef, NULL); CTFrameDraw(frame, context); CFRelease(frame); CFRelease(frameSetter); CFRelease(pathRef); // And, for the magic touch, flip the whole view AFTER everything is drawn [self.layer setAffineTransform:CGAffineTransformMakeScale(1, -1)]; </code></pre> <p>Now everything is drawn from top to bottom, left to right, right side up</p> <p><img src="https://i.stack.imgur.com/9h1kw.png" alt="Core Text correctly laid out on asymmetric shape in iOS"></p>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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