core-graphics

Transparent Ring in iOS

社会主义新天地 提交于 2019-12-01 12:31:41
I have a circle avatar on my view. I make it like this: self.imageView.layer.cornerRadius = 75; self.imageView.layer.masksToBounds = YES; self.imageView.layer.borderWidth = 1; self.imageView.layer.borderColor = [UIColor whiteColor].CGColor; But I want transparent 2px ring between avatar and white border. I can't draw a white circle on the background, because the avatar can move and ring position will be lost. I have the idea to stroke path using CGContextSetBlendMode(context, kCGBlendModeClear); after assigning the layer, but I don't catch how exactly do it. Appreciate for your help. that

Transparent Ring in iOS

我的未来我决定 提交于 2019-12-01 12:21:58
问题 I have a circle avatar on my view. I make it like this: self.imageView.layer.cornerRadius = 75; self.imageView.layer.masksToBounds = YES; self.imageView.layer.borderWidth = 1; self.imageView.layer.borderColor = [UIColor whiteColor].CGColor; But I want transparent 2px ring between avatar and white border. I can't draw a white circle on the background, because the avatar can move and ring position will be lost. I have the idea to stroke path using CGContextSetBlendMode(context,

Draw VU meter using Core Graphics in iOS

纵然是瞬间 提交于 2019-12-01 11:10:14
I'm trying to draw a somewhat similar image to this, using Core Graphics: I was able to draw the main arc, but I am not able to understand, how to divide arc into parts/draw graduation on arc? My current code to draw the arc is: [path addArcWithCenter:point radius:radius startAngle:DEGREES_TO_RADIANS(specific_start_angle) endAngle:DEGREES_TO_RADIANS(specific_end_angle) clockwise:NO]; I tried using strokeWithBlendMode but I am facing problem with position of graduations or ticks. Teja's solution will work fine for you , but it does require that you calculate your own start and end points for

Draw/Paint like sketch color inside a bezier path in UIView

﹥>﹥吖頭↗ 提交于 2019-12-01 10:40:15
I am drawing a shape layer with help of a UIBezier Path on a UIView : CAShapeLayer *pathLayer = [CAShapeLayer layer]; pathLayer.frame=CGRectMake(-view.frame.origin.x, -view.frame.origin.y, view.frame.size.width, view.frame.size.height); pathLayer.path = path.CGPath; pathLayer.strokeColor = [[UIColor blackColor] CGColor]; pathLayer.fillColor = [[UIColor clearColor] CGColor]; //pathLayer.fillColor = nil; pathLayer.lineWidth = 6.0; pathLayer.lineJoin = kCALineJoinBevel; [view.layer addSublayer:pathLayer]; On touch points I want to paint on that UIView, for that I am doing : -(void)touchesBegan:

Textured Line in CG

喜你入骨 提交于 2019-12-01 10:35:29
问题 I am working on a Drawing App for iOS. In this app i need to draw textured lines. For this i am using this method.But texture is so small and not in shape. I want to know what i did wrong and how can i resolve it. Here is my updated code- CGPoint mid1 = midPoint(previousPoint1, previousPoint2); CGPoint mid2 = midPoint(currentPoint, previousPoint1); [curImage drawAtPoint:CGPointMake(0, 0)]; CGContextRef context = UIGraphicsGetCurrentContext(); [self.layer renderInContext:context];

UIGraphicsGetCurrentContext() short lifetime

隐身守侯 提交于 2019-12-01 10:28:39
I have a view which implements freehand drawing, but I have a small problem. I noticed on the iPad 3 that everything went to hell, so I tried to update my drawing code (probably as I should have done in the first place) to only update the portion that was stroked. However, the first stroke after open, and the first stroke after about 10 seconds of idle are extremely slow. After everything is "warmed up" it is smooth as butter and only takes about 0.15ms per drawRect. I don't know why, but the whole view rectangle is getting marked as dirty for the first drawRect, and the first drawRect after

Fill Color Animation Flickers when calling block in animation did stop

一曲冷凌霜 提交于 2019-12-01 09:22:23
Im having trouble figuring out why the animation is flickering from the fromValue to the toValue after my animation block is complete. I know that after you complete an animation you have to set the values of the CALayer to the end state of the animation to keep it looking consistent. Yet no matter what order i call these methods in i keep getting the flickering result. What I'm doing is drawing a checkmark with a biezer path and then once the strokeEnd animation is complete i fill in the check mark by animating the fillColor property. The fill in checkmark function and reset checkmark

CoreGraphics Image resize

时光总嘲笑我的痴心妄想 提交于 2019-12-01 09:01:49
This code is from Apple's WWDC 2011 Session 318 - iOS Performance in Depth and uses CoreGraphics to create thumbnails from server hosted images. CGImageSourceRef src = CGImageSourceCreateWithURL(url); NSDictionary *options = (CFDictionaryRef)[NSDictionary dictionaryWithObject:[NSNumber numberWithInt:1024 forKey:(id)kCGImageSourceThumbnailMaxPixelSize]; CGImageRef thumbnail = CGImageSourceCreateThumbnailAtIndex(src,0,options); UIImage *image = [UIImage imageWithCGImage:thumbnail]; CGImageRelease(thumbnail); CGImageSourceRelease(src); But it doesnt work and the docs don't really help. In the iOS

MKOverlay View is blurred

你离开我真会死。 提交于 2019-12-01 08:25:26
问题 I'm trying to add a png image as a custom map using MKOverlayView. I'm almost there - I am able to get the image lined up in the right place, and I know that the -drawMapRect: method in the subclass of MKOverlayView is being called periodically; I just can't seem to get the image to render properly. It's totally blurry, almost beyond recognition. I also know the image is large enough (it is 1936 × 2967). Here is my code for -drawMapRect: - (void)drawMapRect:(MKMapRect)mapRect zoomScale:

How do I adjust a Quartz 2D context to account for a Retina display?

纵饮孤独 提交于 2019-12-01 08:09:30
I have a Quartz 2D game which draws directly onto a context. For this reason I am having to adapt the code so that it scales if appropriate for a Retina display. I am doing this using the following code: - (CGFloat) displayScale { if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) { return [[UIScreen mainScreen]scale]; } else { return 1.0; } } What I am now struggling with is how to manipulate my Quartz context in my -drawRect: method to mulitply by the returned scale value. Can anyone help me with this code ? Brad Larson You don't need to change anything in your Quartz code to