Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Try this:</p> <pre><code>- (void)initValues { UIColor *gray = [UIColor colorWithRed:0.0f green:0.0f blue:0.0f alpha:0.3f]; CALayer *l = [self layer]; l.masksToBounds = YES; l.cornerRadius = 10.0f; l.borderWidth = 3.0f; self.backgroundColor = gray; l.backgroundColor = gray.CGColor; l.borderColor = gray.CGColor; } - (void)drawRect:(CGRect)rect { NSLog(@"TTT_WantsToBeRazorSharpView drawRect[%3.2f,%3.2f][%3.2f,%3.2f]",rect.origin.x,rect.origin.y,rect.size.width,rect.size.height); // get the graphic context CGContextRef ctx = UIGraphicsGetCurrentContext(); CGContextSetShouldSmoothFonts(ctx,YES); CGColorRef colorWhite = CGColorRetain([UIColor redColor].CGColor); CGContextSetFillColorWithColor(ctx, colorWhite); CGContextSelectFont(ctx, "Helvetica-Bold", 24, kCGEncodingMacRoman); CGAffineTransform tranformer = CGAffineTransformMakeScale(1.0, -1.0); CGContextSetTextMatrix(ctx, tranformer); //why is this sucker blurry? NSString*txtPleaseHelp = NSLocalizedString(@"Hello, am I blurry again?",@""); CGContextShowTextAtPoint(ctx, 10, 50, [txtPleaseHelp cStringUsingEncoding:NSMacOSRomanStringEncoding], [txtPleaseHelp length]); CGColorRelease(colorWhite); } - (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx { if (!layer.shouldRasterize &amp;&amp; !CGRectIsEmpty(UIGraphicsGetPDFContextBounds())) { [self drawRect:self.bounds]; } else { [super drawLayer:layer inContext:ctx]; } } </code></pre> <p>I had to change the text color to red to make it visible. Because the text is written first, then the transparent grey button is placed over it, it would make the white text disappear. When adding the drawLayer method, everything that does not need to be rasterized is written as vector to pdf, making the text also selectable.</p>
 

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