ios - iphone When using UIGraphicsGetCurrentContext in drawRect to draw a rectangle, is there an excess of 1 pixel outside the border?
我想大声告诉你
我想大声告诉你 2017-05-16 13:18:51
0
1
847

code show as below

-(void) drawRect:(CGRect)rect{
//CGContextRef context = UIGraphicsGetCurrentContext();
//CGContextSetRGBFillColor(context, 0.0, 0.0, 0.0, 0.2);
[[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.2]setFill];
CGRect grayRect = self.frame;
UIRectFill(grayRect);

CGRect cropRect = _intersectionRect;
CGRect intersectionRect = CGRectIntersection(cropRect, grayRect);
[[UIColor clearColor]setFill];
UIRectFill(intersectionRect);
}

In the demo of the blank project, everything is ok

But in my own project, there are extra 1px and borders with different transparency. How to solve it?

我想大声告诉你
我想大声告诉你

reply all(1)
刘奇

问题解决,两个rect的值应该都设置为int而不是float。

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!