圓角矩形

CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetRGBStrokeColor(context, 1.0, 0.0, 0.0, 1.0); CGContextSetLineWidth(context, 1.0); CGFloat radious = 15.0f; CGContextMoveToPoint(context, radious + 10 , self.y + 20); CGContextAddLineToPoint(context, self.width - radious - 10, self.y + 20); CGContextAddArc(context, self.width - radious - 10, self.y + radious + 20, radious, - M_PI_2,0, NO);io

CGContextAddLineToPoint(context, self.width - 10, self.height - 20 - radious); CGContextAddArc(context, self.width - radious - 10, self.height - 20 - radious , radious, 0, M_PI_2, NO);di

CGContextAddLineToPoint(context, radious + 10, self.height - 20 ); CGContextAddArc(context, radious + 10, self.height - 20 - radious, radious, M_PI_2, M_PI, NO); // no是順時針,右邊爲0,12點鐘方向是-π/2co

CGContextAddLineToPoint(context, 10, self.y + 20 + radious); CGContextAddArc(context, radious + 10, self.y + 20 + radious, radious, M_PI, - M_PI_2, NO); CGContextStrokePath(context);radio

[super drawRect:rect];context

相關文章
相關標籤/搜索