Permalink
Browse files

added reversesTitleShadowWhenHighlighted to TUIButton and made TUIBut…

…ton respect the current title shadow color
  • Loading branch information...
1 parent 8658c36 commit a286f98c2cdc84ffe9c4cd4c426c5cf784251ab6 @joshaber joshaber committed May 18, 2012
Showing with 21 additions and 0 deletions.
  1. +3 −0 lib/UIKit/TUIButton.h
  2. +18 −0 lib/UIKit/TUIButton.m
View
@@ -45,6 +45,7 @@ typedef enum {
unsigned int dimsInBackground:1;
unsigned int buttonType:8;
unsigned int firstDraw:1;
+ unsigned int reversesTitleShadowWhenHighlighted:1;
} _buttonFlags;
}
@@ -62,6 +63,8 @@ typedef enum {
@property(nonatomic,readonly,strong) TUILabel *titleLabel;
@property(nonatomic,readonly,strong) TUIImageView *imageView;
+@property (nonatomic, assign) BOOL reversesTitleShadowWhenHighlighted;
+
- (CGRect)backgroundRectForBounds:(CGRect)bounds;
- (CGRect)contentRectForBounds:(CGRect)bounds;
- (CGRect)titleRectForContentRect:(CGRect)contentRect;
View
@@ -41,6 +41,7 @@ - (id)initWithFrame:(CGRect)frame
_buttonFlags.firstDraw = 1;
self.backgroundColor = [TUIColor clearColor];
self.needsDisplayWhenWindowsKeyednessChanges = YES;
+ self.reversesTitleShadowWhenHighlighted = NO;
}
return self;
}
@@ -206,6 +207,7 @@ - (void)drawRect:(CGRect)r
_titleView.text = self.currentTitle;
_titleView.textColor = self.currentTitleColor;
+ _titleView.renderer.shadowColor = self.currentTitleShadowColor;
CGContextRef ctx = TUIGraphicsGetCurrentContext();
CGContextSaveGState(ctx);
@@ -254,4 +256,20 @@ - (void)_stateDidChange {
[self setNeedsDisplay];
}
+- (void)setHighlighted:(BOOL)highlighted {
+ if(self.highlighted != highlighted) {
+ _titleView.renderer.shadowOffset = CGSizeMake(_titleView.renderer.shadowOffset.width, -_titleView.renderer.shadowOffset.height);
+ }
+
+ [super setHighlighted:highlighted];
+}
+
+- (BOOL)reversesTitleShadowWhenHighlighted {
+ return _buttonFlags.reversesTitleShadowWhenHighlighted;
+}
+
+- (void)setReversesTitleShadowWhenHighlighted:(BOOL)reversesTitleShadowWhenHighlighted {
+ _buttonFlags.reversesTitleShadowWhenHighlighted = reversesTitleShadowWhenHighlighted;
+}
+
@end

0 comments on commit a286f98

Please sign in to comment.