有没有办法304 Not Modified用 Alamofire 4检测响应?我发现response.statusCode即使服务器以 304 响应,Alamofire也始终为 200。
网络通话设置:
Alamofire
.request("http://domain.com/api/path", method: .get)
.validate(statusCode: 200..<300)
.validate(contentType: ["application/json"])
.responseJSON { response in
print(response.response?.statusCode)
}
Run Code Online (Sandbox Code Playgroud)
Alamofire 响应头
<NSHTTPURLResponse: 0x61800003e1c0> { URL: http://domain.com/api/path } { status code: 200, headers {
"Access-Control-Allow-Headers" = "content-type, authorization";
"Access-Control-Allow-Methods" = "GET, PUT, POST, DELETE, HEAD, OPTIONS";
"Access-Control-Allow-Origin" = "*";
"Cache-Control" = "private, must-revalidate";
Connection = "keep-alive";
"Content-Type" = "application/json";
Date = "Mon, 23 Jan 2017 23:35:00 GMT";
Etag = "\"f641...cbb6\"";
"Proxy-Connection" = "Keep-alive"; …Run Code Online (Sandbox Code Playgroud) 如何改变CALayer动画的方向和起始位置?
例如,如果我使用以下代码为圆形设置动画:
-(void)drawCircle {
CAShapeLayer *circleShapeLayer = [[CAShapeLayer alloc] init];
circleShapeLayer.path = [self circleBezierPath].CGPath;
circleShapeLayer.strokeColor = [UIColor lightGrayColor].CGColor;
circleShapeLayer.fillColor = [UIColor clearColor].CGColor;
circleShapeLayer.lineWidth = 2;
[self.view.layer addSublayer:circleShapeLayer];
CABasicAnimation *circleShapeAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
circleShapeAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
circleShapeAnimation.duration = 1.0f;
circleShapeAnimation.fromValue = @(0.0f);
circleShapeAnimation.toValue = @(1.0f);
[circleShapeLayer addAnimation:circleShapeAnimation forKey:@"strokeEnd"];
}
-(UIBezierPath *)circleBezierPath {
UIBezierPath *circlePath = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(100, 100, 100, 100)];
return circlePath;
}
Run Code Online (Sandbox Code Playgroud)
动画始终从3点开始,并以顺时针方向动画.
如何强制它从12点(或任何其他位置)开始并以逆时针方向制作动画?