使用QuartzCore在UIView周围绘制边框会导致边框比视图小1 px;

时间:2014-07-30 12:56:53

标签: ios objective-c uiview quartz-core

我尝试使用以下代码绘制自定义视图,但由于某种原因边框呈现错误,顶部有小间隙。

    self.infoContainerView = [[UIView alloc] initWithFrame:CGRectMake(12, (self.contentImage.image.size.height/self.contentImage.image.size.width)*320.0-50), self.view.frame.size.width - 24, self.view.frame.size.height - self.contentImage.frame.size.height - 24)];
    self.infoContainerView.backgroundColor = [UIColor whiteColor];
    self.infoContainerView.layer.borderWidth = 0.5f;
    self.infoContainerView.layer.borderColor = [[[UIColor blackColor] colorWithAlphaComponent:0.15f] CGColor];

这就是结果:

http://i.stack.imgur.com/GLHs5.png

1 个答案:

答案 0 :(得分:0)

尝试给出像

这样的边框颜色
self.infoContainerView.layer.borderColor = [[UIColor blackColor] CGColor];