0
我很難過爲什麼這個形狀不會生成其他路徑。我試過演示CABasicAnimations哪些工作..如果任何人有任何想法,將是驚人的!爲什麼不是這種形狀動畫?
#import "AKTabBar.h"
@implementation AKTabBar
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
//customize tab bar
}
return self;
}
-(void)awakeFromNib {
CAShapeLayer* tabBarShape = [CAShapeLayer layer];
UIBezierPath* discoverPath = [UIBezierPath bezierPath];
[discoverPath moveToPoint: CGPointMake(0, 98)];
[discoverPath addLineToPoint: CGPointMake(0, 98)];
[discoverPath addLineToPoint: CGPointMake(0, -0)];
[discoverPath addLineToPoint: CGPointMake(27.91, -0)];
[discoverPath addLineToPoint: CGPointMake(34, 7)];
[discoverPath addLineToPoint: CGPointMake(39.78, -0)];
[discoverPath addLineToPoint: CGPointMake(320, -0)];
[discoverPath addLineToPoint: CGPointMake(320, 98)];
[discoverPath closePath];
UIBezierPath* sharePath = [UIBezierPath bezierPath];
[sharePath moveToPoint: CGPointMake(0, 98)];
[sharePath addLineToPoint: CGPointMake(0, 98)];
[sharePath addLineToPoint: CGPointMake(0, -0)];
[sharePath addLineToPoint: CGPointMake(40, -0)];
[sharePath addLineToPoint: CGPointMake(47, 7)];
[sharePath addLineToPoint: CGPointMake(39.78, -0)];
[sharePath addLineToPoint: CGPointMake(320, -0)];
[sharePath addLineToPoint: CGPointMake(200, 98)];
[sharePath closePath];
tabBarShape.path=discoverPath.CGPath;
tabBarShape.fillColor = [UIColor redColor].CGColor;
// UIImageView* menu = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"tabBarBackground"]];
[self.layer addSublayer:tabBarShape];
// menu.layer.mask=tabBarShape;
// [ self addSubview:menu];
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"discoverPath"];
animation.duration = 4.0;
animation.toValue = (__bridge id)(sharePath.CGPath);
[tabBarShape addAnimation:animation forKey:@"discoverPath"];
}
@end
啊謝謝你! 1的問題,我已removeOnCompletion設置爲NO,但它仍然將其刪除時完成.. – jfisk
[嘗試設置動畫的'fillMode'到'kCAFillModeForwards'。](http://stackoverflow.com/questions/1166721/what-does- fillmode-do-exactly?rq = 1) –
同一個人兩次... –