这是我第一次绘制,所以它必须是一件很愚蠢的,但我的drawRect:方法不起作用...... 这里是我的代码:绘制在Objective-C
- (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);
}
它根本不起作用,还是不像您所期望的那样画?另外,为什么哦为什么'#定义中心? – mattjgalloway 2012-04-20 12:06:38
这只是尝试'#define',我可以离开它。它并没有画出来,我在IB中添加了一个UIView,并将该类设置为我的类“FaceView”(是的,Stanford cs193p) – 11684 2012-04-20 12:08:05
我总是忘记:@mattjgalloway – 11684 2012-04-20 12:08:48