Skip to content

Commit

Permalink
++
Browse files Browse the repository at this point in the history
++
  • Loading branch information
RyeWhiskey authored and RyeWhiskey committed Jun 30, 2016
1 parent f007b65 commit d29f105
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 49 deletions.
3 changes: 3 additions & 0 deletions RWCompleteCutView.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

#import <UIKit/UIKit.h>
#import "Masonry.h"

@class RWCardContentView,RWCompleteCutViewCell,RWCardContentView;

Expand Down Expand Up @@ -57,6 +58,8 @@ typedef NS_ENUM(NSInteger,RWContentView)

@property (nonatomic,strong)NSIndexPath *indexPath;

- (void)didInThisView;

@end

@interface RWCompleteCutView : UICollectionView
Expand Down
113 changes: 70 additions & 43 deletions RWCompleteCutView.m
Original file line number Diff line number Diff line change
Expand Up @@ -175,19 +175,33 @@ @interface RWCompleteCutViewCell ()

@property (nonatomic,assign)CGFloat angles;

@property (nonatomic,assign)CGFloat centerX;

@property (nonatomic,assign)CGFloat centerY;

@property (nonatomic,assign)CGFloat x;

@property (nonatomic,assign)CGFloat y;

@end

@implementation RWCompleteCutViewCell

@synthesize angles,centerX,centerY,x,y;

- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];

if (self)
{
[self initViews];
[self setDefaultValueWithView];
if (!_numberLabel)
{
[self initViews];
}

[self autoLayoutViews];
[self setDefaultValueWithView];
}

return self;
Expand Down Expand Up @@ -308,8 +322,45 @@ - (void)setNumber:(NSString *)number
_numberLabel.text = _number;
}

- (void)didInThisView
{
RWCardContentView *translucentView = _contentViews[RWContentViewOfTranslucent];

RWCardContentView *mainView = _contentViews[RWContentViewOfMain];

[UIView animateWithDuration:0.05f animations:^{

CGAffineTransform transform = GetCGAffineTransformRotateAroundPoint(centerX, centerY, x, y, 0.02f);

mainView.transform = transform;

} completion:^(BOOL finished) {

angles = 0;

CGAffineTransform transform = GetCGAffineTransformRotateAroundPoint(centerX, centerY, x, y, angles);

translucentView.transform = transform;

[UIView animateWithDuration:0.2f animations:^{

mainView.transform = transform;
}];
}];

}

- (void)revolveViewsWithPanGesture:(UIPanGestureRecognizer *)panGesture
{
if (!x && !y && !centerX && !centerY)
{
centerX = panGesture.view.center.x;
centerY = panGesture.view.center.y;

x = centerX;
y = panGesture.view.bounds.size.height * 2;
}

CGPoint distance = [panGesture translationInView:self];

RWCardContentView *translucentView = _contentViews[RWContentViewOfTranslucent];
Expand All @@ -319,12 +370,6 @@ - (void)revolveViewsWithPanGesture:(UIPanGestureRecognizer *)panGesture
panGesture.view.transform = CGAffineTransformIdentity;
translucentView.transform = CGAffineTransformIdentity;

CGFloat centerX = panGesture.view.center.x;
CGFloat centerY = panGesture.view.center.y;

CGFloat x = centerX;
CGFloat y = panGesture.view.bounds.size.height * 2;

if (_contentDatas.count == 1 && distance.x < 0.0f)
{
translucentView.alpha = 0.0f;
Expand All @@ -336,9 +381,9 @@ - (void)revolveViewsWithPanGesture:(UIPanGestureRecognizer *)panGesture

panGesture.view.transform = transform;

_angles = 0;
angles = 0;

transform = GetCGAffineTransformRotateAroundPoint(centerX,centerY,x,y,_angles);
transform = GetCGAffineTransformRotateAroundPoint(centerX,centerY,x,y,angles);

translucentView.transform = transform;

Expand All @@ -353,13 +398,13 @@ - (void)revolveViewsWithPanGesture:(UIPanGestureRecognizer *)panGesture
return;
}

_angles += [self revolveAngleWithDistance:distance.x];
angles += [self revolveAngleWithDistance:distance.x];

CGAffineTransform transform = GetCGAffineTransformRotateAroundPoint(centerX, centerY, x, y, _angles);
CGAffineTransform transform = GetCGAffineTransformRotateAroundPoint(centerX, centerY, x, y, angles);

CGAffineTransform transformLucent = GetCGAffineTransformRotateAroundPoint(centerX, centerY, x, y, _angles / 4);
CGAffineTransform transformLucent = GetCGAffineTransformRotateAroundPoint(centerX, centerY, x, y, angles / 4);

if (_angles <= 0)
if (angles <= 0)
{
panGesture.view.transform = transform;

Expand All @@ -373,7 +418,7 @@ - (void)revolveViewsWithPanGesture:(UIPanGestureRecognizer *)panGesture

if (panGesture.state == UIGestureRecognizerStateEnded)
{
if (_angles < -0.15f)
if (angles < -0.15f)
{
__block CGAffineTransform transform = GetCGAffineTransformRotateAroundPoint(centerX, centerY, x, y, -0.5);

Expand All @@ -382,33 +427,13 @@ - (void)revolveViewsWithPanGesture:(UIPanGestureRecognizer *)panGesture
panGesture.view.transform = transform;

} completion:^(BOOL finished) {

self.userInteractionEnabled = NO;

[_delegate revolveDidChangeViewWithState:RWChangeViewStateToNextView];

[UIView animateWithDuration:0.05f animations:^{

transform = GetCGAffineTransformRotateAroundPoint(centerX, centerY, x, y, 0.02f);

panGesture.view.transform = transform;

} completion:^(BOOL finished) {

_angles = 0;

transform = GetCGAffineTransformRotateAroundPoint(centerX, centerY, x, y, _angles);

translucentView.transform = transform;

[UIView animateWithDuration:0.2f animations:^{

panGesture.view.transform = transform;
}];
}];
}];
}
else if (_angles > 0.15f)
else if (angles > 0.15f)
{
if (_indexPath.row == 0)
{
Expand All @@ -419,14 +444,14 @@ - (void)revolveViewsWithPanGesture:(UIPanGestureRecognizer *)panGesture

panGesture.view.transform = transform;

_angles = 0;
angles = 0;

transform = GetCGAffineTransformRotateAroundPoint(centerX,centerY,x,y,_angles);
transform = GetCGAffineTransformRotateAroundPoint(centerX,centerY,x,y,angles);

translucentView.transform = transform;

[UIView animateWithDuration:0.2f animations:^{

panGesture.view.transform = transform;
}];

Expand All @@ -437,9 +462,9 @@ - (void)revolveViewsWithPanGesture:(UIPanGestureRecognizer *)panGesture
{
[UIView animateWithDuration:0.3f animations:^{

_angles = 0;
angles = 0;

CGAffineTransform transform = GetCGAffineTransformRotateAroundPoint(centerX, centerY, x, y, _angles);
CGAffineTransform transform = GetCGAffineTransformRotateAroundPoint(centerX, centerY, x, y, angles);

panGesture.view.transform = transform;
translucentView.transform = transform;
Expand Down Expand Up @@ -493,7 +518,7 @@ - (CGFloat)revolveAngleWithDistance:(CGFloat)distance

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
_angles = 0.0f;
angles = 0.0f;

return YES;
}
Expand Down Expand Up @@ -688,6 +713,8 @@ - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cell
cell.contentDatas = _viewSource[indexPath.row];
cell.delegate = self;

[cell didInThisView];

return cell;
}

Expand Down
12 changes: 6 additions & 6 deletions ZhongYuSubjectHubKY.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@
1263F6B01CDB34E00089EC9F /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1263F6AF1CDB34E00089EC9F /* JavaScriptCore.framework */; };
1263F6B21CDB34F70089EC9F /* libstdc++.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 1263F6B11CDB34F70089EC9F /* libstdc++.tbd */; };
1268F1B91CE0482D0040AB2F /* RWClassListModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 1268F1B81CE0482D0040AB2F /* RWClassListModel.m */; };
1269C9921D23A64C0012D85F /* RWCompleteCutView.m in Sources */ = {isa = PBXBuildFile; fileRef = 1269C9911D23A64C0012D85F /* RWCompleteCutView.m */; };
127154A41D23ACFB00F24FF9 /* DWCustomPlayerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1271549B1D23ACFB00F24FF9 /* DWCustomPlayerViewController.m */; };
127154A51D23ACFB00F24FF9 /* DWMediaSubtitle.m in Sources */ = {isa = PBXBuildFile; fileRef = 1271549D1D23ACFB00F24FF9 /* DWMediaSubtitle.m */; };
127154A61D23ACFB00F24FF9 /* DWPlayerMenuView.m in Sources */ = {isa = PBXBuildFile; fileRef = 1271549F1D23ACFB00F24FF9 /* DWPlayerMenuView.m */; };
Expand Down Expand Up @@ -421,6 +420,7 @@
12F4461D1D129A1C00511336 /* Lv8.png in Resources */ = {isa = PBXBuildFile; fileRef = 12F446131D129A1C00511336 /* Lv8.png */; };
12F4461E1D129A1C00511336 /* Lv9.png in Resources */ = {isa = PBXBuildFile; fileRef = 12F446141D129A1C00511336 /* Lv9.png */; };
12F446221D12AE4A00511336 /* edit_t.png in Resources */ = {isa = PBXBuildFile; fileRef = 12F446211D12AE4A00511336 /* edit_t.png */; };
12F45C711D24A476001A7990 /* RWCompleteCutView.m in Sources */ = {isa = PBXBuildFile; fileRef = 12F45C701D24A476001A7990 /* RWCompleteCutView.m */; };
12F5671E1D07D6E30059E20F /* RWSubjectCatalogueController.m in Sources */ = {isa = PBXBuildFile; fileRef = 12F5671D1D07D6E30059E20F /* RWSubjectCatalogueController.m */; };
12F6EB301CD9FA1900CBA632 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 12F6EB2F1CD9FA1900CBA632 /* WebKit.framework */; };
12F6EB331CD9FA3E00CBA632 /* RWWebViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 12F6EB321CD9FA3E00CBA632 /* RWWebViewController.m */; };
Expand Down Expand Up @@ -939,8 +939,6 @@
1263F6B11CDB34F70089EC9F /* libstdc++.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = "libstdc++.tbd"; path = "usr/lib/libstdc++.tbd"; sourceTree = SDKROOT; };
1268F1B71CE0482D0040AB2F /* RWClassListModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RWClassListModel.h; sourceTree = "<group>"; };
1268F1B81CE0482D0040AB2F /* RWClassListModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RWClassListModel.m; sourceTree = "<group>"; };
1269C9901D23A64C0012D85F /* RWCompleteCutView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RWCompleteCutView.h; sourceTree = "<group>"; };
1269C9911D23A64C0012D85F /* RWCompleteCutView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RWCompleteCutView.m; sourceTree = "<group>"; };
1271549A1D23ACFB00F24FF9 /* DWCustomPlayerViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DWCustomPlayerViewController.h; sourceTree = "<group>"; };
1271549B1D23ACFB00F24FF9 /* DWCustomPlayerViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DWCustomPlayerViewController.m; sourceTree = "<group>"; };
1271549C1D23ACFB00F24FF9 /* DWMediaSubtitle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DWMediaSubtitle.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1183,6 +1181,8 @@
12F446131D129A1C00511336 /* Lv8.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Lv8.png; sourceTree = "<group>"; };
12F446141D129A1C00511336 /* Lv9.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Lv9.png; sourceTree = "<group>"; };
12F446211D12AE4A00511336 /* edit_t.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = edit_t.png; sourceTree = "<group>"; };
12F45C6F1D24A476001A7990 /* RWCompleteCutView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RWCompleteCutView.h; sourceTree = "<group>"; };
12F45C701D24A476001A7990 /* RWCompleteCutView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RWCompleteCutView.m; sourceTree = "<group>"; };
12F5671C1D07D6E30059E20F /* RWSubjectCatalogueController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RWSubjectCatalogueController.h; sourceTree = "<group>"; };
12F5671D1D07D6E30059E20F /* RWSubjectCatalogueController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RWSubjectCatalogueController.m; sourceTree = "<group>"; };
12F5E2911D19160B004A303A /* RWRequestIndex.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RWRequestIndex.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1509,8 +1509,8 @@
children = (
1263F5C11CDB11F20089EC9F /* RWInformationViewController.h */,
1263F5C21CDB11F20089EC9F /* RWInformationViewController.m */,
1269C9901D23A64C0012D85F /* RWCompleteCutView.h */,
1269C9911D23A64C0012D85F /* RWCompleteCutView.m */,
12F45C6F1D24A476001A7990 /* RWCompleteCutView.h */,
12F45C701D24A476001A7990 /* RWCompleteCutView.m */,
1268F1B71CE0482D0040AB2F /* RWClassListModel.h */,
1268F1B81CE0482D0040AB2F /* RWClassListModel.m */,
127154991D23ACE000F24FF9 /* Video */,
Expand Down Expand Up @@ -3605,7 +3605,6 @@
12FFF09D1CCF18FF003F58E2 /* main.m in Sources */,
12EDD8381CE3372600C9FBB8 /* RWAlarmClockController.m in Sources */,
12F23BC01CE970170086A699 /* RWRecommendController.m in Sources */,
1269C9921D23A64C0012D85F /* RWCompleteCutView.m in Sources */,
1261693E1D10FAF70055438B /* UMComGridTableViewCell.m in Sources */,
BAF4EF621CD1B20500C3931B /* RWAnswerViewController.m in Sources */,
12DFC63D1D138D8F00C73FDF /* RWRegisterViewController.m in Sources */,
Expand Down Expand Up @@ -3719,6 +3718,7 @@
12FFF1331CCF3C63003F58E2 /* NSManagedObjectContext+MagicalSaves.m in Sources */,
12F814F81CE42E3400D6DEE9 /* RWClockPickView.m in Sources */,
BAF4EF681CD1B36900C3931B /* RWAnswerViewCell.m in Sources */,
12F45C711D24A476001A7990 /* RWCompleteCutView.m in Sources */,
BAF3C59B1CD49F4300D66B03 /* RWCollectsubject.m in Sources */,
126169171D10FAF70055438B /* UMComPhotoAlbumViewController.m in Sources */,
12F776641CF2B06100F3561A /* RWMainViewController+Drawer.m in Sources */,
Expand Down
Binary file not shown.

0 comments on commit d29f105

Please sign in to comment.