ios - iphone 在drawRect中使用UIGraphicsGetCurrentContext畫矩形,邊框外有1像素的多餘?
我想大声告诉你
我想大声告诉你 2017-05-16 13:18:51
0
1
937

程式碼如下

-(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);
}

在空白專案的Demo中,一切ok

#但是在我自己的專案中,有多餘的1px,透明度不同的邊框,請問怎麼解決?

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

全部回覆(1)
刘奇

問題解決,兩個rect的值應該都設定為int而不是float。

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!