Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions KYCuteViewDemo/KYCuteView.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,21 @@ - (id)initWithFrame:(CGRect)frame {
}

- (void)displayLinkAction {
[self countDistance];
pointA = CGPointMake(x1 - r1 * cosDigree, y1 + r1 * sinDigree); // A
pointB = CGPointMake(x1 + r1 * cosDigree, y1 - r1 * sinDigree); // B
pointD = CGPointMake(x2 - r2 * cosDigree, y2 + r2 * sinDigree); // D
pointC = CGPointMake(x2 + r2 * cosDigree, y2 - r2 * sinDigree); // C
pointO = CGPointMake(pointA.x + (centerDistance / 2) * sinDigree,
pointA.y + (centerDistance / 2) * cosDigree);
pointP = CGPointMake(pointB.x + (centerDistance / 2) * sinDigree,
pointB.y + (centerDistance / 2) * cosDigree);

[self drawRect];
}

- (void)countDistance
{
x1 = backView.center.x;
y1 = backView.center.y;
x2 = self.frontView.center.x;
Expand All @@ -74,19 +89,8 @@ - (void)displayLinkAction {
}

r1 = oldBackViewFrame.size.width / 2 - centerDistance / self.viscosity;

pointA = CGPointMake(x1 - r1 * cosDigree, y1 + r1 * sinDigree); // A
pointB = CGPointMake(x1 + r1 * cosDigree, y1 - r1 * sinDigree); // B
pointD = CGPointMake(x2 - r2 * cosDigree, y2 + r2 * sinDigree); // D
pointC = CGPointMake(x2 + r2 * cosDigree, y2 - r2 * sinDigree); // C
pointO = CGPointMake(pointA.x + (centerDistance / 2) * sinDigree,
pointA.y + (centerDistance / 2) * cosDigree);
pointP = CGPointMake(pointB.x + (centerDistance / 2) * sinDigree,
pointB.y + (centerDistance / 2) * cosDigree);

[self drawRect];
}

}
- (void)drawRect {
backView.center = oldBackViewCenter;
backView.bounds = CGRectMake(0, 0, r1 * 2, r1 * 2);
Expand Down Expand Up @@ -197,6 +201,7 @@ - (void)handleDragGesture:(UIPanGestureRecognizer *)ges {
[shapeLayer removeFromSuperlayer];

self.frontView.center = oldBackViewCenter;
[self countDistance];
[self AddAniamtionLikeGameCenterBubble];
}
}];
Expand Down