0
我在自定義UIButton內使用drawRect繪製了一個帶有圖像的邊框按鈕。代碼如下:IOS:drawRect在角落顯示1px
- (void) drawRect:(CGRect)rect {
CGContextRef context = UIGraphicsGetCurrentContext();
//Draw a rectangle
CGContextSetFillColorWithColor(context, [UIColor clearColor].CGColor);
CGContextSetStrokeColorWithColor(context, [[UIColor grayColor] CGColor]);
//Define a rectangle
CGRect drawrect = CGRectMake(CGRectGetMinX(rect),CGRectGetMinY(rect),rect.size.width,rect.size.height);
CGContextStrokeRect(context,drawrect);}
問題是,在角落我得到了一個額外的像素(見附圖)。我究竟做錯了什麼?
感謝
「我在做什麼錯?」 - 你正在調整圖像的大小以至於看不到它:) – 2012-01-29 20:14:46