#pragma mark - UIScrollViewDelegate
-(void)scrollViewDidScroll:(UIScrollView *)scrollView {
CGFloat height = -scrollView.contentOffset.y;
UIBezierPath *path = [UIBezierPath bezierPath];
[path moveToPoint:CGPointMake(0, 0)];
[path addLineToPoint:CGPointMake(self.view.width, 0)];
if (height <= 100) {
//偏移值小于等于100的时候,底部绘制直线
[path addLineToPoint:CGPointMake(self.view.width, height)];
[path addLineToPoint:CGPointMake(0, height)];
}else{
//偏移值大于100的时候,底部绘制曲线
[path addLineToPoint:CGPointMake(self.view.width, 100)];
[path addQuadCurveToPoint:CGPointMake(0, 100) controlPoint:CGPointMake(self.view.center.x, height)];
}
[path closePath];
self.shapeLayer.path = path.CGPath;
}
#pragma mark - private method
-(void)p_initCircle {
self.circleLayer.frame = CGRectMake(0, 0, self.view.width, 100);
self.circleLayer.fillColor = nil;
self.circleLayer.strokeColor = [UIColor whiteColor].CGColor;
self.circleLayer.lineWidth = 2.0;
CGPoint center = CGPointMake(self.view.center.x, 50);
UIBezierPath *path = [UIBezierPath bezierPath];
[path moveToPoint:CGPointMake(self.view.center.x, 35)];
[path addArcWithCenter:center radius:15 startAngle:-M_PI_2 endAngle:M_PI * 1.5 clockwise:YES];
CGFloat r1 = 17.0;
CGFloat r2 = 22.0;
for (int i = 0; i < 8 ; i++) {
CGPoint pointStart = CGPointMake(center.x + sin((M_PI * 2.0 / 8 * i)) * r1, center.y - cos((M_PI * 2.0 / 8 * i)) * r1);
CGPoint pointEnd = CGPointMake(center.x + sin((M_PI * 2.0 / 8 * i)) * r2, center.y - cos((M_PI * 2.0 / 8 * i)) * r2);
[path moveToPoint:pointStart];
[path addLineToPoint:pointEnd];
}
self.circleLayer.path = path.CGPath;
}
#pragma mark - UIScrollViewDelegate
-(void)scrollViewDidScroll:(UIScrollView *)scrollView {
CGFloat height = -scrollView.contentOffset.y;
if (height <= 100) {
//偏移值小于等于100的时候,绘制对应的路径
self.circleLayer.strokeEnd = height / 100.0;
}else{
//偏移值大于100的时候,绘制全路径
self.circleLayer.strokeEnd = 1.0;
}
}
#pragma mark - UIScrollViewDelegate
-(void)scrollViewDidScroll:(UIScrollView *)scrollView {
CGFloat height = -scrollView.contentOffset.y;
[CATransaction begin];
[CATransaction setDisableActions:YES];
if (height <= 100) {
//偏移值小于等于100的时候,不旋转
self.circleLayer.affineTransform = CGAffineTransformIdentity;
}else{
//偏移值小于等于100的时候,旋转
self.circleLayer.affineTransform = CGAffineTransformMakeRotation(-(M_PI / 720 * height - 100));
}
[CATransaction commit];
}
-(void)p_rise {
self.tableView.scrollEnabled = NO;
CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
anim.duration = 0.15;
anim.toValue = @(M_PI / 4.0);
anim.repeatCount = MAXFLOAT;
[self.circleLayer addAnimation:anim forKey:nil];
}
-(void)p_stop {
self.tableView.scrollEnabled = YES;
[self.tableView setContentOffset:CGPointMake(0, 0) animated:YES];
[self.circleLayer removeAllAnimations];
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有