我使用AFNetworking从我的Web服务中检索数据,每件事情都完美无缺,但我想检测超时错误.我在请求的故障块中使用了这段代码但是我没有工作
failure:^(AFHTTPRequestOperation *operation, NSError *error) {
if ([operation.response statusCode] == 408) {
//time out error here
}
}];
Run Code Online (Sandbox Code Playgroud)
代码408通常用于超时错误
我需要你帮助使用uibezierpath或类似的方法在UIView上绘制这个边框.
我已经做了这个解决方案:在另一个中嵌入一个UIView,但我认为有更好的解决方案:
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
self.theView.layer.cornerRadius = self.theView.bounds.size.width/2;
self.theView.layer.masksToBounds = YES;
UIView *borderView = [[UIView alloc] initWithFrame:CGRectMake(4, 4, CGRectGetWidth(self.theView.frame) - 8, CGRectGetHeight(self.theView.frame) - 8)];
borderView.backgroundColor = [UIColor grayColor];
borderView.layer.cornerRadius = self.theView.bounds.size.width/2;
borderView.layer.masksToBounds = YES;
self.theView.layer.borderWidth = 2;
self.theView.layer.borderColor = [UIColor redColor].CGColor;
self.theView.backgroundColor = [UIColor clearColor];
[self.theView addSubview:borderView];
}
Run Code Online (Sandbox Code Playgroud)
谢谢.