Last active
August 29, 2015 13:57
-
-
Save kopiro/9757845 to your computer and use it in GitHub Desktop.
Set the shadow for all Titanium Elements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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