注册

ASDefaultPlaybackButton 参数类型兼容问题,运行报错

+ (void)drawRect:(CGRect)bounds withParameters:(id)parameters isCancelled:(asdisplaynode_iscancelled_block_t)isCancelledBlock isRasterizing:(BOOL)isRasterizing

{

  ASDefaultPlaybackButtonType buttonType = (ASDefaultPlaybackButtonType)[parameters[@"buttonType"] intValue];

  UIColor *color = parameters[@"color"];
 
parameters 类型为ID类型,取值的时候是按nsdictionary类型使用,运行报错,有人和我一样的问题吗?
已邀请:

KevinGong

赞同来自: xiaobao

ASDefaultPlaybackButton 你这是哪里的代码? 看样子是用了AsyncDisplayKit?
 
我看到官方最新的代码是这样的
 
+ (void)drawRect:(CGRect)bounds withParameters:(NSDictionary *)parameters isCancelled:(asdisplaynode_iscancelled_block_t)isCancelledBlock isRasterizing:(BOOL)isRasterizing
{
ASDefaultPlaybackButtonType buttonType = (ASDefaultPlaybackButtonType)[parameters[@"buttonType"] intValue];
UIColor *color = parameters[@"color"];

CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
UIBezierPath* bezierPath = [UIBezierPath bezierPath];
if (buttonType == ASDefaultPlaybackButtonTypePlay) {
[bezierPath moveToPoint: CGPointMake(0, 0)];
[bezierPath addLineToPoint: CGPointMake(0, bounds.size.height)];
[bezierPath addLineToPoint: CGPointMake(bounds.size.width, bounds.size.height/2)];
[bezierPath addLineToPoint: CGPointMake(0, 0)];
[bezierPath closePath];
} else if (buttonType == ASDefaultPlaybackButtonTypePause) {
CGFloat pauseSingleLineWidth = bounds.size.width / 3.0;
[bezierPath moveToPoint: CGPointMake(0, bounds.size.height)];
[bezierPath addLineToPoint: CGPointMake(pauseSingleLineWidth, bounds.size.height)];
[bezierPath addLineToPoint: CGPointMake(pauseSingleLineWidth, 0)];
[bezierPath addLineToPoint: CGPointMake(0, 0)];
[bezierPath addLineToPoint: CGPointMake(0, bounds.size.height)];
[bezierPath closePath];
[bezierPath moveToPoint: CGPointMake(pauseSingleLineWidth * 2, 0)];
[bezierPath addLineToPoint: CGPointMake(pauseSingleLineWidth * 2, bounds.size.height)];
[bezierPath addLineToPoint: CGPointMake(bounds.size.width, bounds.size.height)];
[bezierPath addLineToPoint: CGPointMake(bounds.size.width, 0)];
[bezierPath addLineToPoint: CGPointMake(pauseSingleLineWidth * 2, 0)];
[bezierPath closePath];
}

[color setFill];
[bezierPath fill];

CGContextRestoreGState(context);
}
是的,已经修改了,确实去你所描述的~谢谢

要回复问题请先登录注册