forked from DenTelezhkin/Shapes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0b71f42
commit c80f714
Showing
19 changed files
with
1,559 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,22 @@ | ||
# CocoaPods | ||
# | ||
# We recommend against adding the Pods directory to your .gitignore. However | ||
# you should judge for yourself, the pros and cons are mentioned at: | ||
# http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control? | ||
# | ||
# Pods/ | ||
# Xcode | ||
.DS_Store | ||
*/build/* | ||
*.pbxuser | ||
!default.pbxuser | ||
*.mode1v3 | ||
!default.mode1v3 | ||
*.mode2v3 | ||
!default.mode2v3 | ||
*.perspectivev3 | ||
!default.perspectivev3 | ||
xcuserdata | ||
*.moved-aside | ||
DerivedData | ||
.idea/ | ||
*.hmap | ||
*.xccheckout | ||
|
||
#CocoaPods | ||
Pods | ||
Podfile.lock | ||
*.xcworkspace |
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 @@ | ||
// | ||
// RoundDimmedView.h | ||
// GeoTourist | ||
// | ||
// Created by Denys Telezhkin on 23.07.14. | ||
// Copyright (c) 2014 MLSDev. All rights reserved. | ||
// | ||
|
||
#import "ShapedView.h" | ||
|
||
@interface DimmedView : ShapedView | ||
|
||
-(void)makeVisiblePath:(UIBezierPath *)visiblePath | ||
dimmedPath:(UIBezierPath *)dimmedPath; | ||
|
||
@property (nonatomic, assign) float opacity; | ||
@property (nonatomic, strong) UIColor * dimmingColor; | ||
|
||
@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,52 @@ | ||
// | ||
// RoundDimmedView.m | ||
// GeoTourist | ||
// | ||
// Created by Denys Telezhkin on 23.07.14. | ||
// Copyright (c) 2014 MLSDev. All rights reserved. | ||
// | ||
|
||
#import "DimmedView.h" | ||
|
||
@implementation DimmedView | ||
|
||
-(void)commonSetup | ||
{ | ||
self.opacity = 0.9; | ||
self.dimmingColor = [UIColor blackColor]; | ||
} | ||
|
||
-(instancetype)initWithFrame:(CGRect)frame | ||
{ | ||
if (self = [super initWithFrame:frame]) | ||
{ | ||
[self commonSetup]; | ||
} | ||
return self; | ||
} | ||
|
||
-(instancetype)initWithCoder:(NSCoder *)aDecoder | ||
{ | ||
if (self = [super initWithCoder:aDecoder]) | ||
{ | ||
[self commonSetup]; | ||
} | ||
return self; | ||
} | ||
|
||
-(void)makeVisiblePath:(UIBezierPath *)visiblePath dimmedPath:(UIBezierPath *)dimmedPath | ||
{ | ||
[visiblePath setUsesEvenOddFillRule:YES]; | ||
|
||
[dimmedPath appendPath:visiblePath]; | ||
[dimmedPath setUsesEvenOddFillRule:YES]; | ||
|
||
CAShapeLayer *fillLayer = [CAShapeLayer layer]; | ||
fillLayer.path = dimmedPath.CGPath; | ||
fillLayer.fillRule = kCAFillRuleEvenOdd; | ||
fillLayer.fillColor = self.dimmingColor.CGColor; | ||
fillLayer.opacity = self.opacity; | ||
[self.layer addSublayer:fillLayer]; | ||
} | ||
|
||
@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 @@ | ||
// | ||
// ProgressView.h | ||
// GeoTourist | ||
// | ||
// Created by Denys Telezhkin on 17.07.14. | ||
// Copyright (c) 2014 MLSDev. All rights reserved. | ||
// | ||
|
||
#import "ShapedView.h" | ||
|
||
@interface ProgressView : ShapedView | ||
|
||
-(void)setFrame:(CGRect)frame; | ||
|
||
@property (nonatomic, assign) float progress; | ||
|
||
@property (nonatomic, strong) UIColor * fillColor; | ||
|
||
@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,59 @@ | ||
// | ||
// ProgressView.m | ||
// GeoTourist | ||
// | ||
// Created by Denys Telezhkin on 17.07.14. | ||
// Copyright (c) 2014 MLSDev. All rights reserved. | ||
// | ||
|
||
#import "ProgressView.h" | ||
|
||
@implementation ProgressView | ||
|
||
-(void)setFrame:(CGRect)frame | ||
{ | ||
UIBezierPath * path = [UIBezierPath bezierPath]; | ||
path.lineWidth = frame.size.height; | ||
[path moveToPoint:CGPointMake(0, frame.size.height/2)]; | ||
[path addLineToPoint:CGPointMake(frame.size.width, frame.size.height/2)]; | ||
self.path = path; | ||
[super setFrame:frame]; | ||
} | ||
|
||
static NSString * const kStrokeEndAnimationKey = @"Stroke end animation"; | ||
|
||
-(void)setProgress:(float)progress | ||
{ | ||
NSParameterAssert(progress>=0); | ||
|
||
if (progress>1) | ||
{ | ||
progress =1; | ||
} | ||
|
||
[self.shapeLayer removeAnimationForKey:kStrokeEndAnimationKey]; | ||
|
||
[CATransaction begin]; | ||
|
||
CABasicAnimation * drawAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"]; | ||
drawAnimation.fromValue = @(self.shapeLayer.strokeEnd); | ||
drawAnimation.toValue = @(progress); | ||
drawAnimation.duration = 0.05; | ||
drawAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]; | ||
drawAnimation.removedOnCompletion = YES; | ||
|
||
self.shapeLayer.strokeEnd = progress; | ||
_progress = progress; | ||
|
||
[self.shapeLayer addAnimation:drawAnimation forKey:kStrokeEndAnimationKey]; | ||
[CATransaction commit]; | ||
} | ||
|
||
-(void)setFillColor:(UIColor *)fillColor | ||
{ | ||
self.shapeLayer.strokeColor = [fillColor CGColor]; | ||
self.shapeLayer.masksToBounds = YES; | ||
_fillColor = fillColor; | ||
} | ||
|
||
@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,16 @@ | ||
// | ||
// ShapedView.h | ||
// GeoTourist | ||
// | ||
// Created by Denys Telezhkin on 17.07.14. | ||
// Copyright (c) 2014 MLSDev. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface ShapedView : UIView | ||
|
||
@property (nonatomic, strong) UIBezierPath * path; | ||
@property (nonatomic, strong, readonly) CAShapeLayer * shapeLayer; | ||
|
||
@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,30 @@ | ||
// | ||
// ShapedView.m | ||
// GeoTourist | ||
// | ||
// Created by Denys Telezhkin on 17.07.14. | ||
// Copyright (c) 2014 MLSDev. All rights reserved. | ||
// | ||
|
||
#import "ShapedView.h" | ||
|
||
@implementation ShapedView | ||
|
||
+(Class)layerClass | ||
{ | ||
return [CAShapeLayer class]; | ||
} | ||
|
||
-(CAShapeLayer *)shapeLayer | ||
{ | ||
return (CAShapeLayer*)self.layer; | ||
} | ||
|
||
-(void)setPath:(UIBezierPath *)path | ||
{ | ||
_path = path; | ||
self.shapeLayer.path = [_path CGPath]; | ||
self.shapeLayer.lineWidth = path.lineWidth; | ||
} | ||
|
||
@end |
Oops, something went wrong.