core-animation

iPhoneSDK calculate Rotation angle from CATransform3D

这一生的挚爱 提交于 2019-12-18 10:24:10
问题 How do I calculate the Rotation in Radians around Z-axis by giving a CATransform3D struct as the input? basically what I need is the other way round of CATransform3DMakeRotation . 回答1: It depends on what axis you are doing the rotation on. Rotation about the z-axis is represented as: a = angle in radians x' = x*cos.a - y*sin.a y' = x*sin.a + y*cos.a z' = z ( cos.a sin.a 0 0) (-sin.a cos.a 0 0) ( 0 0 1 0) ( 0 0 0 1) so angle should be a = atan2(transform.m12, transform.m11); Rotation about x

(Scale) Zoom into a UIView at a point

雨燕双飞 提交于 2019-12-18 10:16:26
问题 Something I don't understand about transformations. I want to zoom in to say the top right corner of a UIView (the main view). I use CGAffineTransformScale and have tried both setting the center/anchorPoint as well as CGAffineTransformMakeTranslation to no avail. I can't figure out how to set the translation properly so that it will zoom in on this point. CGAffineTransform tr = CGAffineTransformScale(self.view.transform, 2, 2); [UIView animateWithDuration:2.5 delay:0 options:0 animations:^{

Core Animation - modify animation property

你离开我真会死。 提交于 2019-12-18 09:24:04
问题 I have animation func startRotate360() { let rotation : CABasicAnimation = CABasicAnimation(keyPath: "transform.rotation.z") rotation.fromValue = 0 rotation.toValue = Double.pi * 2 rotation.duration = 1 rotation.isCumulative = true rotation.repeatCount = Float.greatestFiniteMagnitude self.layer.add(rotation, forKey: "rotationAnimation") } What I want is ability to stop animation by setting its repeat count to 1, so it completes current rotation (simply remove animation is not ok because it

How to let a view rotate forever?

风格不统一 提交于 2019-12-18 06:13:14
问题 Is there a way to let a view rotate forever, with an specified speed? I need that for an indicator kind of thing. I know there is this weird Lxxxxx00ff constant (don't remember it exactly) that stands for "forever". 回答1: You can use HUGE_VAL for floating value (if I remember correctly, repeatCount property for animation is a float). To setup animation you can create CAAnimation object using +animationWithKeyPath: method: CABasicAnimation* animation = [CABasicAnimation animationWithKeyPath:@

Core Animation or OpenGL ES?

无人久伴 提交于 2019-12-18 05:04:29
问题 I want to do the following: Tap the screen and draw 3 cricles around the the tapped point. Is it better to do this with Core Animation or OpenGL ES? Where do I start? 回答1: As mentioned, the Core Graphics framework is probably what you want. A good way to go about it would be to subclass UIView, then override the two methods drawRect: and touchesEnded:withEvent: . When a touch event ends on the UIView, you can get the point of the last touch from the event passed to touchesEnded:withEvent: ,

Animate a UIView along a part of a bezier path

强颜欢笑 提交于 2019-12-18 05:03:49
问题 I'm trying animate a UIView along a portion of a bezier path. I found a way to move the the view to any part of the path using this code: let animation = CAKeyframeAnimation(keyPath: "position") animation.path = trackPath.cgPath animation.rotationMode = kCAAnimationRotateAuto animation.speed = 0 animation.timeOffset = offset animation.duration = 1 animation.calculationMode = kCAAnimationPaced square.layer.add(animation, forKey: "animate position along path") However, this just moves the view

Turn a page (a UIWebView) with an animation

南楼画角 提交于 2019-12-18 03:01:06
问题 I have a webview, which shows the pages of a ebook. I want to switch from one page to the next page with a page curl animation. By now, I know how to switch the page and how to apply a page curl animation on the webview. But how do I apply the curl animation in a way that it looks like flipping from one page to another? 回答1: Here's some downloadable code with an example of how to do this. 回答2: I think you required to use "WebKit CSS animation" for getting animation in UIWebView. Read DashCode

Adding CIFilter to CALayer under Mavericks?

拜拜、爱过 提交于 2019-12-18 01:57:22
问题 so this is the standard way of adding filter to a layer: NSView *view = self.window.contentView; view.wantsLayer = YES; CATextLayer *textLayer = [CATextLayer layer]; textLayer.frame = CGRectMake(10.0, 10.0, 200.0, 100.0); textLayer.string = @"foo"; textLayer.foregroundColor = [[NSColor redColor] CGColor]; // Add filter CIFilter *filter = [CIFilter filterWithName:@"CIGaussianBlur" keysAndValues:@"inputRadius", @5.0, nil]; textLayer.filters = @[filter]; // Attach layer [view.layer addSublayer

UIView.animateWithDuration swift loop animation

只愿长相守 提交于 2019-12-17 22:44:23
问题 In ViewController.Swift I managed to make a box animate from one point to another. I thought it would be easy to loop this so the box will animate to one point and then animate back to its original position and then loop again. I have managed to move the object to a position and in "complete" move it back again, but that doesn't make i loop. How can this be achieved? I thought maybe this could work but i honestly don't know: let boxmoves = [CGRect(x: 120, y: 220, width: 100, height: 100),

Mask a UIView with a cut-out circle

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-17 22:23:49
问题 I’ve created a UIView with a semi-transparent black background to sit across my main app’s view. What I’m aiming for here is to create a cut-out circle shape somewhere in that UIView where the semi-transparent black background is not seen, giving the effect of a black mask over the whole image except the circular area (this is to highlight a button in that area). I’ve managed to use CAShapeLayer to create a circular mask, but this has had the opposite effect (i.e. the rest of the view is