Tag:

bezierPathWithRoundedRect不是完美的圈子

我画圈有一些问题: 这个简单的代码表明: – (void)drawRect:(CGRect)rect { self.layer.sublayers = nil; CGFloat radius = self.frame.size.width/2; circle = [CAShapeLayer layer]; circle.path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.width) cornerRadius:radius].CGPath; circle.fillColor = [UIColor clearColor].CGColor; circle.strokeColor = [UIColor redColor].CGColor; circle.lineWidth = 4; [self.layer addSublayer:circle]; CABasicAnimation *drawAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"]; drawAnimation.duration = 1.0; // "animate over 10 seconds or so.." drawAnimation.repeatCount = 1.0; […]

iOS:如何用NSTimer逐步绘制一个圆圈

我想一步一步(如animation计时器)绘制一个没有填充(仅圈的边框)的圆圈。 1旋转等于1天(24小时)。 我真的不知道该怎么做。 我做的步骤 1)我试过https://github.com/danielamitay/DACircularProgress (这是太宽的进展路线) 2)我试图绘制一个有许多弧的圆。 你可以给我一些代码吗? 我真的很困惑。 提前致谢。 编辑 我想使用NSTimer,因为我有一个允许用户停止画圆的button。 如果用户再次触摸一个button – 绘图将不得不继续。

iOS绘图圈子

我正在尝试在iOS应用程序中创build以下圈子。 我知道如何制作这个圈子,但是我不太清楚如何获得弧形点。 它必须在代码中而不是图像。 以下是我目前的代码。 – (void)drawRect:(CGRect)rect { CGPoint point; point.x = self.bounds.origin.x + self.bounds.size.width/2; point.y = self.bounds.origin.y + self.bounds.size.height/2; CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetLineWidth(context, 2.0); CGContextSetStrokeColorWithColor(context, [UIColor blueColor].CGColor); CGRect circle = CGRectMake(point.x/2,point.y-point.x/2,point.x,point.x); CGContextAddEllipseInRect(context, circle); CGContextStrokePath(context); for (int i = 0; i<8; i++) { CGRect circleMini = CGRectMake(??????,??????,point.x/4,point.x/4); CGContextAddEllipseInRect(context, circleMini); CGContextStrokePath(context); } } 更新回答 float cita […]

在Objective-c中绘制圆

我是iPhone编程的初学者。 我需要创build如图1所示的圆圈,它应该分为六个不同的部分,分为四个不同的层次(见图1)。 此外,我需要根据给定的数据创build一个圆圈,如图2所示。每个部分都应该是可点击放大的特定部分(见图3)。 图1:显示了六种不同的颜色,其中两个分为一个,其余四个分为三个部分。 图2:显示不同级别的不同类别的结果。 图3:是select范畴的放大视野。 我有一个故事板载入一个自定义的UIView和使用drawRect方法来绘制圆。 现在的问题是,如何像数字一样创build饼图? 我已经尝试了很多东西,可以使用一些指导 – 或者请举一个例子。 谢谢

如何添加触摸手势映射,但忽略引脚和注释触摸?

我有一个使用MKCircle s来显示某些用户操作的半径信息的mapview。 我想要做的就是允许用户在触摸地图时closuresMKCircle 。 不过,我希望MKCircle不要解雇,如果用户触摸任何其他针或MKCircle本身。 有任何想法吗? 这里是我当前的代码,当地图的任何部分被触摸时,它将closuresMKCircle : UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(deactivateAllRadars)]; [tap setCancelsTouchesInView:NO]; [_mapView addGestureRecognizer:tap];

MKCircle没有更新半径,但正在翻译

我必须将MKCicle绘制成MKMapView。 然后当用户通过滑块改变半径时,我必须重新绘制它。 我删除它,我重新创build它,重新添加到地图。 但是,不要做我期待的,我看到MKCircle在地图上翻译,保持相同的大小。 这是我的代码: – (MKOverlayView *)mapView:(MKMapView *)map viewForOverlay:(id)overlay { MKOverlayView* overlayView = nil; if(overlay == self.circle) { //if we have not yet created an overlay view for this overlay, create it now. if(nil == self.circleView) { self.circleView = [[[MKCircleView alloc] initWithCircle:self.circle] autorelease]; self.circleView.fillColor = [UIColor blueColor]; self.circleView.strokeColor = [UIColor blueColor]; self.circleView.alpha = 50; […]

画一个简单的圆形uiimage

我试图做一个简单的蓝色圆圈的20×20 UIImage。 我尝试使用这个函数,但结果是在一个黑色的方形蓝圈。 如何去除圆周上的黑色方块? function: + (UIImage *)blueCircle { static UIImage *blueCircle = nil; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ UIGraphicsBeginImageContextWithOptions(CGSizeMake(20.f, 20.f), YES, 0.0f); CGContextRef ctx = UIGraphicsGetCurrentContext(); CGContextSaveGState(ctx); CGRect rect = CGRectMake(0, 0, 20, 20); CGContextSetFillColorWithColor(ctx, [UIColor cyanColor].CGColor); CGContextFillEllipseInRect(ctx, rect); CGContextRestoreGState(ctx); blueCircle = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); }); return blueCircle; } 实际结果: