Skip to content

Commit

Permalink
added cornerRadius
Browse files Browse the repository at this point in the history
  • Loading branch information
ehuynh authored and grp committed May 10, 2014
1 parent 88a74e3 commit 4351b1d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 17 deletions.
1 change: 1 addition & 0 deletions pop-tests/POPAnimatablePropertyTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ - (void)testProvidedExistence
kPOPLayerShadowOffset,
kPOPLayerShadowOpacity,
kPOPLayerShadowRadius,
kPOPLayerCornerRadius,
kPOPShapeLayerStrokeStart,
kPOPShapeLayerStrokeEnd,
kPOPShapeLayerStrokeColor,
Expand Down
1 change: 1 addition & 0 deletions pop/POPAnimatableProperty.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
*/
extern NSString * const kPOPLayerBackgroundColor;
extern NSString * const kPOPLayerBounds;
extern NSString * const kPOPLayerCornerRadius;
extern NSString * const kPOPLayerOpacity;
extern NSString * const kPOPLayerPosition;
extern NSString * const kPOPLayerPositionX;
Expand Down
46 changes: 29 additions & 17 deletions pop/POPAnimatableProperty.mm
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@
static CGFloat const kPOPThresholdOpacity = 0.01;
static CGFloat const kPOPThresholdScale = 0.005;
static CGFloat const kPOPThresholdRotation = 0.01;
static CGFloat const kPOPThresholdRadius = 0.01;

#pragma mark - Static

// CALayer
NSString * const kPOPLayerBackgroundColor = @"backgroundColor";
NSString * const kPOPLayerBounds = @"bounds";
NSString * const kPOPLayerCornerRadius = @"cornerRadius";
NSString * const kPOPLayerOpacity = @"opacity";
NSString * const kPOPLayerPosition = @"position";
NSString * const kPOPLayerPositionX = @"positionX";
Expand Down Expand Up @@ -113,7 +115,7 @@
static POPStaticAnimatablePropertyState _staticStates[] =
{
/* CALayer */

{kPOPLayerBackgroundColor,
^(CALayer *obj, CGFloat values[]) {
POPCGColorGetRGBAComponents(obj.backgroundColor, values);
Expand All @@ -136,6 +138,16 @@
kPOPThresholdPoint
},

{kPOPLayerCornerRadius,
^(CALayer *obj, CGFloat values[]) {
values[0] = [obj cornerRadius];
},
^(CALayer *obj, const CGFloat values[]) {
[obj setCornerRadius:values[0]];
},
kPOPThresholdRadius
},

{kPOPLayerPosition,
^(CALayer *obj, CGFloat values[]) {
values_from_point(values, [(CALayer *)obj position]);
Expand Down Expand Up @@ -355,7 +367,7 @@
},
kPOPThresholdRotation
},

{kPOPLayerShadowColor,
^(CALayer *obj, CGFloat values[]) {
POPCGColorGetRGBAComponents(obj.shadowColor, values);
Expand All @@ -367,7 +379,7 @@
},
0.01
},

{kPOPLayerShadowOffset,
^(CALayer *obj, CGFloat values[]) {
values_from_size(values, [obj shadowOffset]);
Expand All @@ -378,7 +390,7 @@
},
0.01
},

{kPOPLayerShadowOpacity,
^(CALayer *obj, CGFloat values[]) {
values[0] = [obj shadowOpacity];
Expand All @@ -388,19 +400,19 @@
},
0.01
},

{kPOPLayerShadowRadius,
^(CALayer *obj, CGFloat values[]) {
values[0] = [obj shadowRadius];
},
^(CALayer *obj, const CGFloat values[]) {
[obj setShadowRadius:values[0]];
},
0.01
kPOPThresholdRadius
},

/* CAShapeLayer */

{kPOPShapeLayerStrokeStart,
^(CAShapeLayer *obj, CGFloat values[]) {
values[0] = obj.strokeStart;
Expand All @@ -420,7 +432,7 @@
},
0.01
},

{kPOPShapeLayerStrokeColor,
^(CAShapeLayer *obj, CGFloat values[]) {
POPCGColorGetRGBAComponents(obj.strokeColor, values);
Expand All @@ -444,9 +456,9 @@
},

#if TARGET_OS_IPHONE

/* UIView */

{kPOPViewAlpha,
^(UIView *obj, CGFloat values[]) {
values[0] = obj.alpha;
Expand Down Expand Up @@ -516,9 +528,9 @@
},
kPOPThresholdScale
},

/* UIScrollView */

{kPOPScrollViewContentOffset,
^(UIScrollView *obj, CGFloat values[]) {
values_from_point(values, obj.contentOffset);
Expand All @@ -538,9 +550,9 @@
},
kPOPThresholdPoint
},

/* UINavigationBar */

{kPOPNavigationBarBarTintColor,
^(UINavigationBar *obj, CGFloat values[]) {
POPUIColorGetRGBAComponents(obj.barTintColor, values);
Expand All @@ -550,9 +562,9 @@
},
kPOPThresholdColor
},

/* UILabel */

{kPOPLabelTextColor,
^(UILabel *obj, CGFloat values[]) {
POPUIColorGetRGBAComponents(obj.textColor, values);
Expand Down

0 comments on commit 4351b1d

Please sign in to comment.