首页 > 代码库 > QQ去除未读状态的动画
QQ去除未读状态的动画
QQ去除未读状态的动画
by 伍雪颖
github代码
- (void)drawRect:(CGRect)rect {
switch (_state) {
caseSRSlimeStateNormal:
{
float percent =1 -distansBetween(_startPoint ,_toPoint) /_viscous;
if (percent ==1) {
CGContextRef context =UIGraphicsGetCurrentContext();
UIBezierPath *path = [UIBezierPathbezierPathWithRoundedRect:CGRectMake(_startPoint.x - _radius,_startPoint.y -_radius,2*_radius,2*_radius)
cornerRadius:_radius];
[selfsetContext:contextpath:path];
CGContextDrawPath(context,kCGPathFillStroke);
}else {
CGFloat startRadius =_radius * (kStartTo + (1-kStartTo)*percent);
CGFloat endRadius =_radius * (kEndTo + (1-kEndTo)*percent);
CGContextRef context =UIGraphicsGetCurrentContext();
UIBezierPath *path = [selfbodyPath:startRadius
end:endRadius
percent:percent];
[selfsetContext:contextpath:path];
CGContextDrawPath(context,kCGPathFillStroke);
if (percent <=0) {
_state =SRSlimeStateShortening;
[selfscaling];
}
}
}
break;
caseSRSlimeStateShortening:
{
_toPoint =CGPointMake((_toPoint.x - _startPoint.x)*0.8 + _startPoint.x,
(_toPoint.y -_startPoint.y)*0.8 + _startPoint.y);
float p =distansBetween(_startPoint,_toPoint) /_viscous;
float percent =1 -p;
float r =_radius * p;
if (p >0.01) {
CGFloat startRadius = r * (kStartTo + (1-kStartTo)*percent);
CGContextRef context =UIGraphicsGetCurrentContext();
CGFloat endRadius = r * (kEndTo + (1-kEndTo)*percent) * (1+percent /2);
UIBezierPath *path = [selfbodyPath:startRadius
end:endRadius
percent:percent];
[selfsetContext:contextpath:path];
CGContextDrawPath(context,kCGPathFillStroke);
}else {
self.hidden =YES;
_state =SRSlimeStateMiss;
}
}
break;
default:
break;
}
switch (_state) {
caseSRSlimeStateNormal:
{
float percent =1 -distansBetween(_startPoint ,_toPoint) /_viscous;
if (percent ==1) {
CGContextRef context =UIGraphicsGetCurrentContext();
UIBezierPath *path = [UIBezierPathbezierPathWithRoundedRect:CGRectMake(_startPoint.x - _radius,_startPoint.y -_radius,2*_radius,2*_radius)
cornerRadius:_radius];
[selfsetContext:contextpath:path];
CGContextDrawPath(context,kCGPathFillStroke);
}else {
CGFloat startRadius =_radius * (kStartTo + (1-kStartTo)*percent);
CGFloat endRadius =_radius * (kEndTo + (1-kEndTo)*percent);
CGContextRef context =UIGraphicsGetCurrentContext();
UIBezierPath *path = [selfbodyPath:startRadius
end:endRadius
percent:percent];
[selfsetContext:contextpath:path];
CGContextDrawPath(context,kCGPathFillStroke);
if (percent <=0) {
_state =SRSlimeStateShortening;
[selfscaling];
}
}
}
break;
caseSRSlimeStateShortening:
{
_toPoint =CGPointMake((_toPoint.x - _startPoint.x)*0.8 + _startPoint.x,
(_toPoint.y -_startPoint.y)*0.8 + _startPoint.y);
float p =distansBetween(_startPoint,_toPoint) /_viscous;
float percent =1 -p;
float r =_radius * p;
if (p >0.01) {
CGFloat startRadius = r * (kStartTo + (1-kStartTo)*percent);
CGContextRef context =UIGraphicsGetCurrentContext();
CGFloat endRadius = r * (kEndTo + (1-kEndTo)*percent) * (1+percent /2);
UIBezierPath *path = [selfbodyPath:startRadius
end:endRadius
percent:percent];
[selfsetContext:contextpath:path];
CGContextDrawPath(context,kCGPathFillStroke);
}else {
self.hidden =YES;
_state =SRSlimeStateMiss;
}
}
break;
default:
break;
}
}
QQ去除未读状态的动画
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。