Thursday, May 30, 2013

UIButton tintColor example in Objective C (iOS).

UIButton tintColor

The tint color for the button.

@property(nonatomic, retain) UIColor *tintColor

Discussion of [UIButton tintColor]
The default value is nil.

This property is not valid for all button types.

UIButton tintColor example.
UISegmentedControl *cancelButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:@"Cancel"]];
[cancelButton setSegmentedControlStyle:UISegmentedControlStyleBar];
[cancelButton setTintColor:[UIColor colorWithRed:0.8 green:0.3 blue:0.3 alpha:1.0]];
[cancelButton setMomentary:YES];
[cancelButton addTarget:self action:@selector(didTapCancel:) forControlEvents:UIControlEventValueChanged];
[self addSubview:cancelButton];
[cancelButton release];

Example of [UIButton tintColor].
self.loginButton.tintColor = [UIColor redColor];

UIButton tintColor example.
UIColor *color = [[UIColor alloc] initWithRed:0.0 green:0.0 blue:0.0 alpha:0.0]; 
button.tintColor = color;

End of UIButton tintColor example article.