Ich versuche, die Schriftart-Eigenschaften eines Textes innerhalb einer Ebene zu ändern, aber es passiert nicht. Könnte jemand aushelfen? Bitte finden Code unten:Schriftgröße und Typ nicht mit CATextLayer
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self)
{
// All HypnosisViews start with a clear background color
[self setBackgroundColor:[UIColor clearColor]];
[self setCircleColor:[UIColor lightGrayColor]];
// Create the new layer object
boxLayer = [[CATextLayer alloc] init];
// Give it a size
[boxLayer setBounds:CGRectMake(0.0, 0.0, 300.0, 85.0)];
// Give it a location
[boxLayer setPosition:CGPointMake(160.0, 350.0)];
// Make half-transparent red the background color for the layer
UIColor *reddish = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.75];
// Get CGColor object with the same color values
CGColorRef cgReddish = [reddish CGColor];
[boxLayer setBackgroundColor:cgReddish];
// Make it a sublayer on the view's layer
[[self layer] addSublayer:boxLayer];
NSString *text2 = @"You are me.";
UIFont *font2 = [UIFont fontWithName:@"Times New Roman" size:10.0];
[text2 sizeWithFont:font2];
[boxLayer setString:text2];
}
return self;
}
Das ist einfach fantastisch. Vielen Dank. Es funktionierte. – Armand
Perfekt - wenn es das ist, was Sie gesucht haben, bitte markieren Sie dies als die richtige Antwort, so dass es für andere sichtbar ist das wurde gelöst! –
Sicher werde ich aber wie mache ich das? Ich bin neu auf dieser Seite. Auch über CATextLayer: Gibt es eine Möglichkeit, Runde Ecke zu runden? Und wie würden Sie Zeilen für einen Text innerhalb der Ebene unterbrechen? – Armand