Thursday, May 30, 2013

UIButton currentTitleColor example in Objective C (iOS).

UIButton currentTitleColor

The color used to display the title. (read-only)

@property(nonatomic, readonly, retain) UIColor *currentTitleColor

Discussion of [UIButton currentTitleColor]
This value is guaranteed not to be nil. The default value is white.

UIButton currentTitleColor example.
UIColor *color = button.currentTitleColor;
button.titleLabel.layer.shadowColor = [color CGColor];
button.titleLabel.layer.shadowRadius = 4.0f;
button.titleLabel.layer.shadowOpacity = .9;
button.titleLabel.layer.shadowOffset = CGSizeZero;
button.titleLabel.layer.masksToBounds = NO;

Example of [UIButton currentTitleColor].
if ([[sfield1 currentTitleColor] isEqual: [UIColor greenColor]])

UIButton currentTitleColor example.
// accessing the currentTitleColor of button1
// and storing in button1CurrentTitleColor
UIColor *button1CurrentTitleColor = [button1 currentTitleColor];
// or UIColor *button1CurrentTitleColor = button1.currentTitleColor;
// then assigning to a second button
[button2 setCurrentTitleColor:button1CurrentTitleColor];

End of UIButton currentTitleColor example article.