-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
iPad compatibility fixes, added shape view
- Loading branch information
Showing
9 changed files
with
157 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// UIColor+PFExtensions.h | ||
// Pants-Framework | ||
// | ||
// Created by Paul Alexander on 10/8/10. | ||
// Copyright (c) 2010 n/a. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import <UIKit/UIKit.h> | ||
|
||
@interface UIColor (PFExtensions) | ||
|
||
+(UIColor *) random; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// UIColor+PFExtensions.m | ||
// Pants-Framework | ||
// | ||
// Created by Paul Alexander on 10/8/10. | ||
// Copyright (c) 2010 n/a. All rights reserved. | ||
// | ||
|
||
#import "UIColor+PFExtensions.h" | ||
|
||
|
||
@implementation UIColor (PFExtensions) | ||
|
||
+(UIColor *) random | ||
{ | ||
return [UIColor colorWithRed: ( arc4random() % 255 ) / 255.0 green: ( arc4random() % 255 ) / 255.0 blue: ( arc4random() % 255 ) / 255.0 alpha: 1]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// PFShapeView.h | ||
// Pants-Framework | ||
// | ||
// Created by Paul Alexander on 10/7/10. | ||
// Copyright (c) 2010 n/a. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
@class CAShapeLayer; | ||
|
||
@interface PFShapeView : UIView | ||
{ | ||
@private | ||
CAShapeLayer * shape; | ||
} | ||
|
||
@property( nonatomic, readonly ) CAShapeLayer * shape; | ||
|
||
-(void) setPoints: (NSArray *) points; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// | ||
// PFShapeView.m | ||
// Pants-Framework | ||
// | ||
// Created by Paul Alexander on 10/7/10. | ||
// Copyright (c) 2010 n/a. All rights reserved. | ||
// | ||
|
||
#import "PFShapeView.h" | ||
#import <QuartzCore/QuartzCore.h> | ||
|
||
|
||
@implementation PFShapeView | ||
|
||
@synthesize shape; | ||
|
||
-(id) initWithFrame: (CGRect) frame | ||
{ | ||
if( self = [super initWithFrame:frame] ) | ||
{ | ||
shape = [[CAShapeLayer alloc] init]; | ||
shape.bounds = CGRectMake( 0, 0, CGRectGetWidth( frame ), CGRectGetHeight( frame ) ); | ||
shape.position = CGPointMake( CGRectGetWidth( frame ) / 2, CGRectGetHeight( frame ) / 2 ); | ||
shape.fillRule = kCAFillRuleNonZero; | ||
|
||
[self.layer addSublayer: shape]; | ||
} | ||
|
||
return self; | ||
} | ||
|
||
-(void) dealloc | ||
{ | ||
SafeRelease( shape ); | ||
|
||
[super dealloc]; | ||
} | ||
|
||
-(void) setPoints: (NSArray *) points | ||
{ | ||
CGMutablePathRef path = CGPathCreateMutable(); | ||
|
||
for( int ix = 0; ix < points.count; ix++ ) | ||
{ | ||
NSValue * val = [points objectAtIndex: ix]; | ||
CGPoint point = [val CGPointValue]; | ||
|
||
if( ix == 0 ) | ||
CGPathMoveToPoint( path, NULL, point.x, point.y ); | ||
else | ||
CGPathAddLineToPoint( path, NULL, point.x, point.y ); | ||
} | ||
|
||
CGPathCloseSubpath( path ); | ||
|
||
shape.path = path; | ||
|
||
CGPathRelease( path ); | ||
|
||
} | ||
|
||
|
||
|
||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters