Skip to content

Instantly share code, notes, and snippets.

@kopiro
Last active August 29, 2015 13:57
Show Gist options
  • Save kopiro/9757845 to your computer and use it in GitHub Desktop.
Save kopiro/9757845 to your computer and use it in GitHub Desktop.
Set the shadow for all Titanium Elements
/* Add to this file: ~/Library/Application Support/Titanium/mobilesdk/osx/3.2.2.GA/iphone/Classes/TiUIView.m */
-(void)setShadow_:(id)args
{
if (args != nil) {
self.layer.masksToBounds = NO;
if ([args objectForKey:@"shadowOffset"] != nil) {
CGPoint p = [TiUtils pointValue: [args objectForKey:@"shadowOffset"]];
CGSize shadowOffset = {p.x,p.y};
self.layer.shadowOffset = shadowOffset;
}
if ([args objectForKey:@"shadowRadius"] != nil) {
self.layer.shadowRadius = [TiUtils floatValue:[args objectForKey:@"shadowRadius"]];
}
if ([args objectForKey:@"shadowOpacity"] != nil) {
self.layer.shadowOpacity = [TiUtils floatValue:[args objectForKey:@"shadowOpacity"]];
}
}
}
/*
Usage in Titanium:
shadow: {
shadowRadius: 2,
shadowOpacity: 0.2,
shadowOffset: { x:2, y:2 }
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment