Skip to content

Instantly share code, notes, and snippets.

@boredzo
Created January 25, 2014 02:02
Show Gist options
  • Save boredzo/8610674 to your computer and use it in GitHub Desktop.
Save boredzo/8610674 to your computer and use it in GitHub Desktop.
Crash-O-Matic banner layer
CATextLayer *crashOMaticLayer = [CATextLayer new];
CGColorRef color = CGColorCreateGenericRGB(1.0, 0.0, 0.0, 1.0);
crashOMaticLayer.backgroundColor = color;
CGColorRelease(color);
crashOMaticLayer.foregroundColor = CGColorGetConstantColor(kCGColorWhite);
crashOMaticLayer.string = @"Special Crash-O-Matic Ed.";
crashOMaticLayer.alignmentMode = kCAAlignmentCenter;
crashOMaticLayer.fontSize = 18.0;
//Your coordinates may vary.
NSSize size = { 300.0, 20.0 };
crashOMaticLayer.bounds = (NSRect){ NSZeroPoint, size };
crashOMaticLayer.zPosition = +1.0;
crashOMaticLayer.contentsScale = 2.0;
[_rootLayer addSublayer:crashOMaticLayer];
crashOMaticLayer.frame = (NSRect){ { -70.0, +70.0 }, size };
[crashOMaticLayer setValue:@(-M_PI_4) forKeyPath:@"transform.rotation.z"];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment