这是我第一次绘图,所以它一定是很愚蠢的东西,但是我的 drawRect: 方法不起作用......这是我的代码:
- (void)drawRect:(CGRect)rect {
CGPoint center = CGPointMake(self.bounds.origin.x + self.bounds.size.width / 2, self.bounds.origin.y + self.bounds.size.height / 2);self.bounds.origin.y + self.bounds.size.height / 2)
CGContextRef ctx = UIGraphicsGetCurrentContext();
[[UIColor redColor] setStroke];
CGFloat radius = (self.bounds.size.width > self.bounds.size.height) ? self.bounds.size.width - 30 : self.bounds.size.height - 30;
CGContextBeginPath(ctx);
CGContextAddArc(ctx, center.x, center.y, radius, 0, 2 * M_PI, YES);
CGContextStrokePath(ctx);
}