Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 使用QuartzCore在UIView周围绘制边框会导致边框比视图小1像素;_Ios_Objective C_Uiview_Quartz Core - Fatal编程技术网

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

Ios 使用QuartzCore在UIView周围绘制边框会导致边框比视图小1像素;,ios,objective-c,uiview,quartz-core,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

我试图用下面的代码绘制一个自定义视图,但由于某些原因,边框在顶部的间隙很小,渲染不正确

    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];
这就是结果:


尝试给边框颜色,如

self.infoContainerView.layer.borderColor = [[UIColor blackColor] CGColor];

尝试将borderWidth更改为1.0fI也尝试过,无论宽度是多少,例如5.0f,它仍然存在:/In the image border color not black color[[UIColor blackColor]CGColor]这将解决此问题。infoContainerView=[[UIView alloc]initWithFrame:cRectMake(12,10,self.view.frame.size.width-24,self.view.frame.size.height-self.contentImage.frame.size.height-24);如果您有白色背景视图,您可以得到问题。我实际发现了问题所在。代码中的y坐标由(self.contentImage.image.size.height/self.contentImage.image.size.width)*320-50给出。当我在上面使用ceilf()时,问题自行解决了。