ios_画圆代码—so_easy!
来源:互联网 发布:windows桥接虚拟机网卡 编辑:程序博客网 时间:2024/05/29 05:04
//画圆圈
-(void)intiUIOfView
{
UIBezierPath *path=[UIBezierPath bezierPath];
NSInteger radius ; // 画圆的弧度
NSInteger circleHeight; //画圆的y轴便宜量
if ([UICommon isHotsPot] == YES) {
circleHeight = iPhone5?43:41;
}else
{
circleHeight = iPhone5?23:21;
}
radius = iPhone5?83:71;
if (self.albumCount >= 10)
{
[path addArcWithCenter:CGPointMake(self.upBtn.frame.origin.x + self.upBtn.frame.size.width/2,self.upBtn.frame.origin.y +self.upBtn.frame.size.height/2+circleHeight) radius:radius startAngle:1.465*2*M_PI+0.535*M_PI endAngle: 1.465*M_PI clockwise:NO];
}
else
{
[path addArcWithCenter:CGPointMake(self.upBtn.frame.origin.x + self.upBtn.frame.size.width/2,self.upBtn.frame.origin.y +self.upBtn.frame.size.height/2+circleHeight) radius:radius startAngle:1.54*2*M_PI+0.465*M_PI endAngle: 1.535*M_PI clockwise:NO];
}
self.arcLayer=[CAShapeLayer layer];
self.arcLayer.path = path.CGPath;//46,169,230
self.arcLayer.fillColor = [UIColor clearColor].CGColor;
self.arcLayer.lineWidth = 2.0f;
self.arcLayer.frame = self.frame;
self.arcLayer.lineCap = kCALineCapRound;//指定线的边缘是圆
self.arcLayer.lineJoin = kCALineCapRound;//终点处理边缘是圆
//大于10绘的颜色是红色否则蓝色
if (self.albumCount >= 10) {
self.arcLayer.strokeColor = [UIColor getColor:@"fe62a4"].CGColor;
// self.arcLayer.strokeColor = [UIColor colorWithRed:255.0/255.0 green:85.0/255.0 blue:157.0/255.0 alpha:1].CGColor;
}
else
{
self.arcLayer.strokeColor = [UIColor getColor:@"00b8bf"].CGColor;
// self.arcLayer.strokeColor = [UIColor colorWithRed:81.0/255.0 green:194.0/255.0 blue:198.0/255.0 alpha:1].CGColor;
}
[self.layer addSublayer:self.arcLayer];
[self drawLineAnimation:self.arcLayer];
}
-(void)drawLineAnimation:(CALayer*)layer
{
[NSTimer scheduledTimerWithTimeInterval:.5 target:self selector:@selector(zoomInAndzoomOut:) userInfo:nil repeats:NO];
CABasicAnimation *bas = [CABasicAnimation animationWithKeyPath:@"strokeStart"];
bas.duration = .8;
bas.delegate = self;
bas.fromValue= [NSNumber numberWithInteger:1];
bas.toValue = [NSNumber numberWithInteger:0];
[layer addAnimation:bas forKey:@"key"];
/*
// 组动画
CAAnimationGroup *groupAnimation = [CAAnimationGroup animation];
groupAnimation.animations = @[bas ];
//设置组动画的时间
groupAnimation.duration = 5;
groupAnimation.fillMode = kCAFillModeForwards;
groupAnimation.removedOnCompletion = NO;
[layer addAnimation:groupAnimation forKey:nil];
*/
}
-(void)intiUIOfView
{
UIBezierPath *path=[UIBezierPath bezierPath];
NSInteger radius ; // 画圆的弧度
NSInteger circleHeight; //画圆的y轴便宜量
if ([UICommon isHotsPot] == YES) {
circleHeight = iPhone5?43:41;
}else
{
circleHeight = iPhone5?23:21;
}
radius = iPhone5?83:71;
if (self.albumCount >= 10)
{
[path addArcWithCenter:CGPointMake(self.upBtn.frame.origin.x + self.upBtn.frame.size.width/2,self.upBtn.frame.origin.y +self.upBtn.frame.size.height/2+circleHeight) radius:radius startAngle:1.465*2*M_PI+0.535*M_PI endAngle: 1.465*M_PI clockwise:NO];
}
else
{
[path addArcWithCenter:CGPointMake(self.upBtn.frame.origin.x + self.upBtn.frame.size.width/2,self.upBtn.frame.origin.y +self.upBtn.frame.size.height/2+circleHeight) radius:radius startAngle:1.54*2*M_PI+0.465*M_PI endAngle: 1.535*M_PI clockwise:NO];
}
self.arcLayer=[CAShapeLayer layer];
self.arcLayer.path = path.CGPath;//46,169,230
self.arcLayer.fillColor = [UIColor clearColor].CGColor;
self.arcLayer.lineWidth = 2.0f;
self.arcLayer.frame = self.frame;
self.arcLayer.lineCap = kCALineCapRound;//指定线的边缘是圆
self.arcLayer.lineJoin = kCALineCapRound;//终点处理边缘是圆
//大于10绘的颜色是红色否则蓝色
if (self.albumCount >= 10) {
self.arcLayer.strokeColor = [UIColor getColor:@"fe62a4"].CGColor;
// self.arcLayer.strokeColor = [UIColor colorWithRed:255.0/255.0 green:85.0/255.0 blue:157.0/255.0 alpha:1].CGColor;
}
else
{
self.arcLayer.strokeColor = [UIColor getColor:@"00b8bf"].CGColor;
// self.arcLayer.strokeColor = [UIColor colorWithRed:81.0/255.0 green:194.0/255.0 blue:198.0/255.0 alpha:1].CGColor;
}
[self.layer addSublayer:self.arcLayer];
[self drawLineAnimation:self.arcLayer];
}
-(void)drawLineAnimation:(CALayer*)layer
{
[NSTimer scheduledTimerWithTimeInterval:.5 target:self selector:@selector(zoomInAndzoomOut:) userInfo:nil repeats:NO];
CABasicAnimation *bas = [CABasicAnimation animationWithKeyPath:@"strokeStart"];
bas.duration = .8;
bas.delegate = self;
bas.fromValue= [NSNumber numberWithInteger:1];
bas.toValue = [NSNumber numberWithInteger:0];
[layer addAnimation:bas forKey:@"key"];
/*
// 组动画
CAAnimationGroup *groupAnimation = [CAAnimationGroup animation];
groupAnimation.animations = @[bas ];
//设置组动画的时间
groupAnimation.duration = 5;
groupAnimation.fillMode = kCAFillModeForwards;
groupAnimation.removedOnCompletion = NO;
[layer addAnimation:groupAnimation forKey:nil];
*/
}
0 0
- ios_画圆代码—so_easy!
- iOS_代码截屏
- iOS_ UITextField相关代码
- iOS_九宫格代码
- iOS_学习代码混淆
- iOS_代码规范
- IOS_代码实现树形导航
- iOS_ 用户引导界面代码
- iOS_抢购倒计时代码备份
- iOS_引入代码块的步骤
- iOS_一些简单地功能代码
- IOS_绘画交集圆填充
- iOS_根据系统版本编译不同的代码
- iOS_崩溃日志分析(定位崩溃代码)
- iOS_如何画1px的线
- iOS_画一像素的线
- iOS_给uiview等设置圆角
- IOS_基础知识
- ios版本判断
- C#中的WebBorwser清除指定域名下的Cookie
- 【新年计划】2015,给程序员的9大计划,没有过于宏伟,不再显得遥不可及
- oracle误删除数据恢复
- 待学习
- ios_画圆代码—so_easy!
- 山水之间
- 友情链接交换的几大注意事项
- 2014年移动互联网不得不说的几件大事:百度小米打车在列
- 错误集
- iOS工程适配64-bit经验分享
- Spring对Hibernate事务管理
- spring beans源码解读之--Bean的注解(annotation)
- 关于javascript中的location