FAQ Database Discussion Community


Core Animation: Unexpected Vertical Flipping on 3D Rotation 'Bounce'

ios,objective-c,animation,core-animation,calayer
I am trying to create a flip transition that contains a grid of CALayer cells that flip over and 'bounce' after they have done so. However, I am encountering a weird vertical flipping issue shown in this video. Without the 'bounce' animation at the end, the animation works as expected,...

Custom Rounded Button without Corner Radius

ios,custom-controls,calayer
how do we subclass a UIbutton and customize it so that it has a round end like this one on Periscope. The Following Button. I would like to PREVENT using layer.CornerRadius though. Using a BezierPath perhaps? but I have a math problem creating the Path. Any thoughts? Thank you ...

Why does my CATextLayer not respond to the contentsGravity property?

objective-c,cocoa,core-animation,calayer,nsview
I am creating a Cocoa app with a layer-backed NSView. I have customised the layer backing the view to be of type CATextlayer because the primary purpose of this view is to display some text. I include the following line in my init procedure and it does not work for...

Draw UIImage in a CALayer

objective-c,uiimage,calayer
Is it possible to draw an existing png image inside a CALayer? If not, how can I have the image as a sublayer of a CALayer?

How do I restart a CALayer animation going on?

ios,osx,cocoa,cocoa-touch,calayer
Apple mentions these two methods for pausing and resuming a CALayer animation going on -(void)pauseLayer:(CALayer*)layer { CFTimeInterval pausedTime = [layer convertTime:CACurrentMediaTime() fromLayer:nil]; layer.speed = 0.0; layer.timeOffset = pausedTime; } -(void)resumeLayer:(CALayer*)layer { CFTimeInterval pausedTime = [layer timeOffset]; layer.speed = 1.0; layer.timeOffset = 0.0; layer.beginTime = 0.0; CFTimeInterval timeSincePause = [layer convertTime:CACurrentMediaTime()...

Setting layer out of layer in UIbutton?

ios,objective-c,uibutton,uiimage,calayer
i want this type of button i have tried pictureBtn which is UIbutton ,i gave it a 5 pixel clear color corner radius and add a picture like camera below but last outer white line how to deal with this can anybody have ideas or something like control. ...

NSScrollView: fade in a top-border like Messages.app

objective-c,cocoa,core-animation,calayer,nsscrollview
What I Want to Do: In Messages.app on OS 10.10, when you scroll the left-most pane (the list of conversations) upwards, a nice horizontal line fades in over about 0.5 seconds. When you scroll back down, the line fades back out. What I Have: I am trying to achieve this...

Remove CALayers from Parent UIView

ios,swift,calayer
There are several questions like this floating around, but no answer that works. I'm adding new CALayers to a UIView like so: func placeNewPicture() { let newPic = CALayer() newPic.contents = self.pictureDragging.contents newPic.frame = CGRect(x: pictureScreenFrame.origin.x - pictureScreenFrame.width/2, y: pictureScreenFrame.origin.y - pictureScreenFrame.height/2, width: pictureScreenFrame.width, height: pictureScreenFrame.height) self.drawingView.layer.addSublayer(newPic) } and trying...

Drawing in UIView on touch points gives blurr drawing effect on boundaries

ios,objective-c,uiview,core-graphics,calayer
To sort out my last problem : Draw/Paint like sketch color inside a bezier path in UIView, I took an exact Image (of path) filled with selected color. Then, to draw that in UIView, for context color I took: lineColor=[UIColor colorWithPatternImage:img]; in drawrect : CGPoint mid1 = midPoint(previousPoint1, previousPoint2); CGPoint...

Change height of layer using caanimation

ios,objective-c,calayer,caanimation
I am learning the caanimations and I face an issue. I want to display a rectangle which height start to 1 and goes to 100. I want this rectangle to stay in the middle of the view and just expand its height. this is the code i made so far:...

How can I access the layer so I can flip it?

ios,objective-c,calayer,core-plot
I implemented corePlot into my xcode project. I'm trying to flip the legend of the graph. Here is the code: CPTGraph *graph = self.hostView.hostedGraph; CPTLegend *theLegend = [CPTLegend legendWithGraph:graph]; graph.legend = theLegend; This is what I tried: theLegend.sublayerTransform = CATransform3DMakeScale( CPTFloat(1.0), CPTFloat(-1.0), CPTFloat(1.0) ); That didn't do anything. So I...

How to get smooth/crisp text on CALayer on OS X

objective-c,cocoa,swift,calayer
Text drawn using Cocoa (OS X) in CALayer and CATextLayer comes out all grainy. What method/approach must be used to get the text to come out crisp/clear? I am happy for the text to be backed by an opaque background - I know that the question would be even more...

How to use NSVisualEffectView in a Layer Host NSView

osx,calayer,nsview,nswindow,nsvisualeffectview
I have a NSView in my OSX app use CALayer doing all sort of animations. This view is a layer host view which contains may small layers. I want to add a NSVisualEffectView with NSVisualEffectBlendingModeBehindWindow blendingMode to support blur transparency effect on Yosemite. The problem is when I turn off...

Is it possible to have a variable height UIView mask layer NOT stretch, and perhaps just sit at the top? (For example, a “torn paper” style edge?)

ios,objective-c,cocoa-touch,uiview,calayer
I can't for the life of me figure out how to create such an effect on a UIView that has dynamic height. I want to have the top have a "torn paper" style edge, but the view can be of dynamic height, so when I set the torn paper mask...

CAShapeLayer with UIRectCornerBottomLeft/Right makes my view disappear

ios,objective-c,uitableview,calayer,cashapelayer
OK. I have done the Google search, the Stack search, the Wenderlich search (is that a meme yet?). I have tried every thing here on overflow and nothing is working. I need a CALayer expert. I have a tableView that I'm showing as a dropdown from the top of my...

How to create a CGPath which exactly match a CALayer bounds when the layer rotate or scale?

ios,calayer,cgpath
We have a CALayer which shows image with edit information. Such as rotate, scale and translate. I want to make a CGPath which exactly match the layer bounds. When the layer rotate, my path should also rotate and its four corners should match the CALayer's four corners. The CGPath is...

Combining multiple CAAnimations in a CALayer hierarchy

ios,core-animation,calayer
I've got this rather simple piece of example code in which I have a simple hierarchy consisting of three layers; view layer |- base layer |- green layer Now I want to move the base layer and at the same time adjust the color of the green layer, so I've...

How could we possibly create this ui concept? [closed]

ios,user-interface,uikit,calayer,uibezierpath
I came across this UI Concept, I couldnt help but to admire it's beauty. I am wondering if it is possible to create a Button that makes (mask) the control below them, to make them look transparent in that area. (In this case UITextField) Please take a look at this...

Swift: remove layer, without removing UIView in UITableViewCell

ios,iphone,swift,uiview,calayer
I have UITableViewCell with UIView in it. I made some CABasicAnimation and attach it to new CAShapeLayer, then I add this layer to my super layer in my UITableViewCell: self.layer.addSublayer(myLayer!) All nice except that myLayer (and his animation) showing above my UIView. I want that label be below UIView. I...

Subtract UIView from another UIView in Swift

ios,swift,calayer,mask
I'm sure this is a very simple thing to do, but I can't seem to wrap my head around the logic. I have two UIViews. One black, semi-transparent and "full-screen" ("overlayView"), another one on top, smaller and resizeable ("cropView"). It's pretty much a crop-view setup, where I want to "dim"...

How do I create a circle with CALayer?

swift,calayer
I have the code below tested, but when I give it constraints it becomes a little small circle: override func drawRect(rect: CGRect) { var path = UIBezierPath(ovalInRect: rect) fillColor.setFill() path.fill() //set up the width and height variables //for the horizontal stroke let plusHeight:CGFloat = 300.0 let plusWidth:CGFloat = 450.0 //create...

Rotating NSString in Swift

swift,nsstring,calayer,quartz-graphics
I'm trying to do something like the attached image. I thought this page would lead to the answer http://www.informit.com/articles/article.aspx?p=2149190&seqNum=13 or Rotating a NSString in drawRect Drawing rotated text with NSString drawInRect but converting objC to swift is troublesome. I can easily draw my arrows but getting the NSString to rotate...

Mask CALayer with Another CALayer

ios,xcode,swift,calayer,mask
I'm trying to mask one CALayer(newSticker) with the image of another layer(stickerMask), like so: func placeSticker(location: CGPoint) { let stickerMask = CALayer() stickerMask.contents = UIImage(contentsOfFile:NSBundle.mainBundle().resourcePath!.stringByAppendingPathComponent("brush\(self.stickerSelected).png"))!.CGImage stickerMask.frame = CGRect(x: location.x * 100, y: location.y * 100, width: 200, height: 200) let newSticker = CALayer() newSticker.backgroundColor = UIColor(red: self.red, green: self.green, blue:...

NSView with masked CIFilter for OS X app

objective-c,calayer,nsview,core-image,cifilter
I am developing an app that contains lots of custom NSView objects being moved around. I have implemented a gaussian blur background filter for one of the custom NSView subclasses like so: - (id)init { self = [super init]; if (self) { ... CIFilter *saturationFilter = [CIFilter filterWithName:@"CIColorControls"]; [saturationFilter setDefaults];...

Pause and resume animations except of rotation in iOS?

ios,animation,rotation,core-animation,calayer
If I need simply to pause/resume rotation then I use the following code: - (void)pauseAnimations { CFTimeInterval paused_time = [self.layer convertTime:CACurrentMediaTime() fromLayer:nil]; self.layer.speed = 0.0; self.layer.timeOffset = paused_time; } - (void)resumeAnimations { CFTimeInterval paused_time = [self.layer timeOffset]; self.layer.speed = 1.0f; self.layer.timeOffset = 0.0f; self.layer.beginTime = 0.0f; CFTimeInterval time_since_pause = [self.layer...

CAGradientLayer is going out of frame of UILabel

ios,objective-c,xcode,calayer,cagradientlayer
I am doing simple things. As I am learning to implement CAGradientLayer. The gradient you see is of Label. I am using autoresizing(not Autolayout). Apart from this have no code written. Autoresizing is not a problem since I've not touched that. CAGradientLayer *gradientLayer = [[CAGradientLayer alloc]init]; gradientLayer.frame = lblHolder.frame; gradientLayer.colors...

How do I get the position of a CALayer subLayer that is arranged via constraints?

objective-c,cocoa,swift,calayer
How can I get the current position of a CALayer instance in the coordinates of its super layer? (Mac application) I would have expected this to be available from the frame property but it isn't. In particular, this CALayer instance has been positioned using various CAConstraint types and I have...

CALayer shadowColor not changing

ios,objective-c,calayer,shadow
So I set the shadow of a layer of an UIView correctly the first time (it shows perfectly fine) but when I try to change the color (nothing else, just the layer.shadowColor) it won't update in the view. It still shows the original color. I already tried layer setNeedsDisplay without...

Using mask to show/hide a view with animation

ios,ios8,calayer,mask,bounds
I am trying to use a mask to hide and show a view, but I cannot get it work correctly for some reason. I am really confused about whether I should animate the frame/bounds/path of the mask. Here is my code to show a view on a button action "GO":...

How to set the background of a CALayer to be transparent without affecting the borders?

objective-c,cocoa,swift,calayer,nsview
I have a layer-backed NSView in my Cocoa application. Using the following code the entire custom view is made transparent: self.layer?.opaque = false self.layer?.opacity = 0 Unfortunately, I need the border of the CALayer to remain visible (and currently it is being made transparent). How best do I go about...

CAShapeLayer strokeColor from image pattern UIColor to CGColor upside down

ios,objective-c,core-graphics,calayer,cashapelayer
I'm using CABasicAnimation to draw all UIBezierPaths i have in an Array using CAShapeLayer CAShapeLayer *shapeLayer = [CAShapeLayer layer]; shapeLayer.path = [path CGPath]; shapeLayer.strokeColor = path.color.CGColor; My path.color is a UIColor from image pattern. When it is converted to CGColor the image pattern is upside down. I know that is...

How to create concave shape of a UIView

ios,uiview,calayer
Is it possible to make a concave shape of the side of a view? I managed to round the edges with border radius, but I wonder if it's possible to make other nice transformations. Here is the example: 1)This is my progress so far: 2)This is how it should be:...

Draw arc segments using UIBezierPath

ios,objective-c,geometry,calayer,uibezierpath
I know there are lots of example related to UIBezierPath, but I am very confused about the angles to use to draw arc, my requirement is like the image below to draw arcs. The length and angle should be calculated as per total number. Right now I have created a...

How to remove the effects of UIView transitionWithView

ios,objective-c,uiview,calayer
Using the code below I have successfully made my UIImageView fade in its image. [UIView transitionWithView:myCell.myImageView duration:2.0 options:UIViewAnimationOptionTransitionCrossDissolve animations:^{ myCell.myImageView.image = myImage; } completion:NULL]; However, when the cell is reused I need to remove this image. When reused it shows the last image(shown before it was reused) and then transitions...

iOS Apply CATransform3D on every frame

ios,core-animation,avfoundation,calayer
I am capturing every frame of vide output and by processing it, I add a CALayer to an overlay which should be transformed according to the results from processing the frame. That CALayer basically knows how to draw an arrow. If I just add the CALayer on every frame it...

How to create a CAAnimation effect like moon rotates around the earth and rotates by itself at the same time in IOS?

ios,calayer,caanimation,anchorpoint
I know it is simple to create the effect making the moon circling around the earth in IOS. Suppose the moon is a CALayer object, just change the anchorPoint of this object to the earth then it will animate circling around the earth. But how to create the moon that...

Animating CALayer background color and update model value

ios,swift,animation,calayer,cabasicanimation
I want to animate a backgroundColor change for a sublayer in my UIView (on tintColorDidChange). I need to animate from the layer's current background colour to the new tint colour several times (different tint colours each time), so the model value for backgroundColor needs to be updated (I can't use...

Swift: Mask Alignment + Auto-Layout Constraints

swift,calayer,mask
I have this PNG file, which I'd like to use as a mask for a UIView. The view must be: 20 pixels/points in from each side A perfect square Centered vertically I set the following constraints to accomplish this: However, it seems these constraints don't play well with masks. When...

Extra CALayer's subLayers in iOS

ios,swift,calayer
I have created a new single view project written in swift and print self.view.layer.sublayers.count. The number is 2, but I haven't add any layer or UIView. override func viewDidLoad() { super.viewDidLoad() println(self.view.layer.sublayers.count) // Do any additional setup after loading the view, typically from a nib. } override func didReceiveMemoryWarning() {...