Quiero aplicar inner-shadow a un UILabel. Tengo una solución, pero no es lo suficientemente buena. ¿Alguien con una mejor solución?Aplicar inner-shadow a UILabel
// UILabel subclass
- (void) drawTextInRect:(CGRect)rect {
CGSize myShadowOffset = CGSizeMake(0, 2);
float myColorValues[] = {255, 0, 0, 1};
CGContextRef myContext = UIGraphicsGetCurrentContext();
CGContextSaveGState(myContext);
CGColorSpaceRef myColorSpace = CGColorSpaceCreateDeviceRGB();
CGColorRef myColor = CGColorCreate(myColorSpace, myColorValues);
CGContextSetShadowWithColor (myContext, myShadowOffset, 5, myColor);
CGContextSetBlendMode(myContext, kCGBlendModeLighten);
[super drawTextInRect:rect];
CGColorRelease(myColor);
CGColorSpaceRelease(myColorSpace);
CGContextRestoreGState(myContext);
}
estoy familiarizado con la propiedad de capa de UILabel, pero shadow offset
nos da una sombra exterior, NO del centro de la sombra (a menos que me falta algo).
¿Has probado los valores negativos en myShadowOffset? – adam