Questions tagged [cglayer]

90 questions
3
votes
1 answer

How to access CGContext for creating CGLayer offscreen

Intention: creating CGLayer offscreen, draw some complicated stuff on it from second thread and use it later for quick drawing on main thread Problem: CGLayerCreateWithContext(context, size, info) expects an already existing CGContext so that it…
weezor
  • 2,621
  • 1
  • 16
  • 10
3
votes
1 answer

Rotating UIControl with CAGradientLayer not updating correctly Swift

Rather than using a normal button, I subclassed a UIControl because I needed to add a gradient to it. I also have a way to add a shadow and an activity indicator (not visible in the image below) as a stateful button to stop users hammering the…
stevenpcurtis
  • 1,907
  • 3
  • 21
  • 47
3
votes
2 answers

Struggling to clear ALL DATA from a CGLayer -- can it even be done?

We're repetitively making a CGLayer, doing processing, and then releasing it. This happens a lot in real time. Surely there is a lot of overhead in making a whole new CGLayer each time. So... Surely it would be better to just keep the layer around,…
Fattie
  • 27,874
  • 70
  • 431
  • 719
3
votes
2 answers

Optimize Core Graphics animated drawing (iPhone)

I have a loop that fires a function 30 times per second. The function changes the position of a couple of points that I use to animate. I draw lines through all the points, meaning that the lines will change 30 times per second. I draw these lines…
Accatyyc
  • 5,798
  • 4
  • 36
  • 51
3
votes
0 answers

Creating a custom animation with CGLayers?

Basically, I want to animate a shrinking circle. I've already done this by drawing progressively smaller circles onto CGLayer's, and then using if(index < 30){ [self performSelector:@selector(showNextLayer) withObject:nil…
Baris
  • 31
  • 2
3
votes
4 answers

Undo/Redo for drawing in iOS

I am working on a drawing app, I want to do Undo/Redo, for this I am saving CGPath on touches ended to NSMutableArray, But I am not understanding how I should render the CGPaths on click of Undo button EDIT1: As I am using BezierPaths, So, I first…
Ranjit
  • 4,576
  • 11
  • 62
  • 121
3
votes
2 answers

Doing Undo and Redo with Cglayer Drawing

I am working with a drawing app, I am using CGlayers for drawing. On touches ended, I get image out of the layer and store it in a Array, which I use to undo operation. My touches ended function -(void)touchesEnded:(NSSet *)touches…
Ranjit
  • 4,576
  • 11
  • 62
  • 121
3
votes
1 answer

Set "opacity" of a CGLayer before draw?

I have UIView subclass - actually a puzzle piece - with 2 different CGLayer initialized at initWithFrame. In drawRect I have to blend this two layer, and the uppermost should have variable alpha depending on game-logic. What is the best (most…
Geri Borbás
  • 15,810
  • 18
  • 109
  • 172
2
votes
1 answer

Draw text to UIView with CATextLayer not working

I am attempting to draw text to a UIView using CATextLayer and so far nothing is showing up. I must be missing something simple. private func drawText(string: String, at: CGPoint, withFont: CGFont, fontColor: CGColor, fontSize: CGFloat) ->…
cHorse1981
  • 111
  • 7
2
votes
1 answer

Adding Rounded Corners to UIImageView vs Pre-Rendering the UIImage?

I am experimenting with the layer of a UIImageView, in particular adding rounded corners. My question is, What is the impact on performance (if any) by doing the following : [self.imgView.layer setCornerRadius:10.0f]; [self.imgView.layer…
MDMonty
  • 363
  • 2
  • 10
2
votes
2 answers

Using CGLayer to Cache Cells in a UITableView

I am trying to improve the performance of scrolling in our app. I have followed all of the generally accepted advice (draw it yourself with CG, the cell is opaque, no subviews, etc.) but it still stutters sometimes when we have background CPU and…
Mark Corner
  • 121
  • 2
  • 7
2
votes
2 answers

Drawing in another thread with CGImage / CGLayer

I have custom UICollectionViewCell subclass where I draw with clipping, stroking and transparency. It works pretty well on Simulator and iPhone 5, but on older devices there is noticeable performance problems. So I want to move time-consuming…
Rinat Khanov
  • 1,566
  • 10
  • 32
2
votes
1 answer

How to use a CGLayer to draw multiple images offscreen

Ultimately I'm working on a box blur function for use on iPhone. That function would take a UIImage and draw transparent copies, first to the sides, then take that image and draw transparent copies above and below, returning a nicely blurred…
willc2
  • 38,991
  • 25
  • 88
  • 99
2
votes
1 answer

Why does my view jump when setting the layer anchorPoint in an animation block?

I have a UIPanGestureRecognizer attached to a view in my iOS app. I copied the code from the Touches sample app for the pan handler. When the gesture starts, my code: Records the original anchor point and center. Changes the anchor point and center…
theory
  • 9,178
  • 10
  • 59
  • 129
2
votes
1 answer

Why CGLayers are not blending?

Why obj2 not blend with obj1 but without use CGLayer it works fine,same problem with CGContextDrawLayerAtPoint,Does CGLayer not support CGContextSetBlendMode?? //Layer CGContextRef context = UIGraphicsGetCurrentContext(); CGLayerRef…