0
使用DrawRect方法繪製一個矩形視圖。我必須設置該特定矩形視圖的半徑拐角。我寫下了一個矩形視圖。如何使用DrawRect方法設置要查看的半徑角?
- (void)drawRect:(CGRect)rect {
int coordinate_x=60,coordinate_y=120,width=200,height=295;
CGContextRef context = UIGraphicsGetCurrentContext();
CGRect drawTank = {coordinate_x, coordinate_y, width, height};
CGColorRef blackColor=[UIColor blackColor].CGColor;
CGContextSetRGBStrokeColor(context, 0, 0, 255, 1);
CGContextSetLineWidth(context, 1.0);
CGContextSetStrokeColorWithColor(context, blackColor);
CGContextStrokeRect(context, drawTank);
}
而我必須使用下面的填充視圖和空視圖使用代碼。
CGRect emptyTank = CGRectMake(coordinate_x, coordinate_y, width, height *(1-filledPercentage));
CGRect fullTank = CGRectMake(coordinate_x, coordinate_y+height *(1-filledPercentage),width, height * filledPercentage);
如何設置特定視圖的半徑拐角。請幫幫我。
在此先感謝。
請發送完整的代碼來繪製半徑角的視圖。 –
我的答案有代碼,它有兩種方法可以做到這一點。你喜歡哪一個?以編程方式創建uiview?或從sotryboard創建它? –