Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The solution is to change the labels's contentsScale to 2 before you draw it, then set it back immediately thereafter. I just coded up a project to verify it, and its working just fine making a 2x image in a normal retina phone (simulator). [If you have a public place I can put it let me know.]</p> <p>EDIT: the extended code walks the subviews and any container UIViews to set/unset the scale</p> <pre><code>- (IBAction)snapShot:(id)sender { [self changeScaleforView:snapView scale:2]; UIGraphicsBeginImageContextWithOptions(snapView.bounds.size, snapView.opaque, 2); [snapView.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *img = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); imageDisplay.image = img; // contentsScale imageDisplay.contentMode = UIViewContentModeScaleAspectFit; [self changeScaleforView:snapView scale:1]; } - (void)changeScaleforView:(UIView *)aView scale:(CGFloat)scale { [aView.subviews enumerateObjectsUsingBlock:^void(UIView *v, NSUInteger idx, BOOL *stop) { if([v isKindOfClass:[UILabel class]]) { v.layer.contentsScale = scale; } else if([v isKindOfClass:[UIImageView class]]) { // labels and images // v.layer.contentsScale = scale; won't work // if the image is not "@2x", you could subclass UIImageView and set the name of the @2x // on it as a property, then here you would set this imageNamed as the image, then undo it later } else if([v isMemberOfClass:[UIView class]]) { // container view [self changeScaleforView:v scale:scale]; } } ]; } </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. 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.
 

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