Skip to content

Instantly share code, notes, and snippets.

@artanisdesign
Last active December 19, 2015 22:29
Show Gist options
  • Save artanisdesign/6027585 to your computer and use it in GitHub Desktop.
Save artanisdesign/6027585 to your computer and use it in GitHub Desktop.
showsTouchWhenHighlighted on Titanium button
-(UIButton*)button
{
if (button==nil)
{
BOOL hasImage = [self.proxy valueForKey:@"backgroundImage"]!=nil;
UIButtonType defaultType = (hasImage==YES) ? UIButtonTypeCustom : UIButtonTypeRoundedRect;
style = [TiUtils intValue:[self.proxy valueForKey:@"style"] def:defaultType];
UIView *btn = [TiButtonUtil buttonWithType:style];
button = (UIButton*)[btn retain];
[self addSubview:button];
if (style==UIButtonTypeCustom)
{
[button setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
}
[button addTarget:self action:@selector(controlAction:forEvent:) forControlEvents:UIControlEventAllTouchEvents];
//------add these lines
if ([TiUtils boolValue:[self.proxy valueForKey:@"showTouch"] def:NO])
{
button.showsTouchWhenHighlighted = YES;
}
//-------
button.exclusiveTouch = YES;
}
if ((viewGroupWrapper != nil) && ([viewGroupWrapper superview]!=button)) {
[viewGroupWrapper setFrame:[button bounds]];
[button addSubview:viewGroupWrapper];
}
return button;
}
var back = Ti.UI.createButton({
height : 44,
width : 48,
//how to use
showTouch : true
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment