2013-08-06 10 views
15

Quanto segue sarà considerato obsoleto in iOS 7: CGContextSelectFont, CGContextShowTextAtPoint. Cosa dovrei usare invece?CGContextShowTextAtPoint deprecato: cosa devo usare ora?

+2

Tutte le modifiche API beta iOS sono in NDA e non possono essere discusse qui. Questo è qualcosa per i forum degli sviluppatori Apple. –

risposta

9

È possibile utilizzare [yourString drawAtPoint:aPoint withAttributes:dictOfAttributes];

Documenti per quel here.

Oppure è sufficiente aggiungere uno UILabel alla propria gerarchia di viste.

2

// inizio contesto grafico UIGraphicsBeginImageContext (imageSize);

//get the context for coreGraphics 
CGContextRef ctx = UIGraphicsGetCurrentContext(); 

CGContextSetTextDrawingMode(ctx, kCGTextFill); 
[[UIColor blackColor] setFill]; 
[@"yourstring" drawAtPoint:CGPointMake(0, 0) withAttributes:@{NSFontAttributeName:[UIFont fontWithName:@"Helvetica" size:17]}]; 
//make image out of bitmap context 
UIImage *outputImage = UIGraphicsGetImageFromCurrentImageContext(); 
Problemi correlati