core-animation

CAEmitterLayer not rendering when -renderInContext: of superlayer is called

☆樱花仙子☆ 提交于 2019-12-01 16:27:15
问题 I have a drawing app and I would like for my users to be able to use particle effects as part of their drawing. Basically, the point of the app is to perform custom drawing and save to Camera Roll or share over the World Wide Web. I encounted the CAEmitterLayer class recently, which I reckon would be a simple and effective way to add particle effects. I have been able to draw the particles onscreen in the app using the CAEmitterLayer implementation. So rendering onscreen works fine. When I go

Set contents of CALayer to animated GIF?

岁酱吖の 提交于 2019-12-01 14:25:10
Is it possible to set the contents of a CALayer to an animated GIF and have it display that animation? I know that I can set the contents to an image like so: CALayer* subLayer = [CALayer layer]; NSImage *image = [[NSImage alloc] initWithData:data]; subLayer.contents = image; And the image will show, but if it's animated, the animation will not display. Is the only solution to get the individual frames for the GIF, get the frame rate, then change the content of the sublayer according to the frame rate? Or is there a much simpler method that I'm overlooking? Swift 3 version, but changed to

Undefined symbol for architecture i386 compile error caused by CACurrentMediaTime()

橙三吉。 提交于 2019-12-01 13:58:43
问题 I'm making an iOS application displaying a timer. I don't think I can keep the timer running after the user presses the home button, so I want to record the time when the user quits the app, and use the time when they reenter the app to update the timer. This is the code I tried: - (void)applicationWillResignActive:(UIApplication *)application { double currentTime = CACurrentMediaTime(); NSLog(@"%g", currentTime); /* Sent when the application is about to move from active to inactive state.

Create masking effect over a view

不打扰是莪最后的温柔 提交于 2019-12-01 12:01:44
I would like to create a masking effect over a UIView in order to accomplish the following. I will display a sealed box in the screen and the user will be able to touch (scratch) the screen in order to reveal whats behind that image(UIView). Something similar to those lottery tickets where u r suppose to scratch some cover material thats on top of the results.. If someone could point me in the right direction would be awesome, I'm not sure how to start doing this... thanks Sorry I'm late. I made some example code which might be of help: https://github.com/oyiptong/CGScratch drawnonward's

iOS UIView Animation CATransform3DMakeRotation confusion

和自甴很熟 提交于 2019-12-01 11:19:41
I have a UIView that I am trying to animate flipping down, while having its axis at the bottom of the view. E.g.: To do this, I am trying to use a UIView animation: [UIView animateWithDuration:3 delay:0 options:UIViewAnimationCurveEaseOut animations:^{ // Flip Down top3.layer.anchorPoint = CGPointMake(0.5, 1.0); top3.layer.transform = CATransform3DMakeRotation(M_PI, 1, 0, 0); } completion:^(BOOL finished) { // Reset? //top3.transform = CGAffineTransformMakeScale(1, 1); }]; Right now it isn't working how I want, it seems like the view is animating AWAY from the user rather then toward. It does

Does iPhone OS support implicit animation?

二次信任 提交于 2019-12-01 09:56:12
问题 Example from Mac OS X: [[aView animator] setFrame:NSMakeRect(100.0,100.0,300.0,300.0)]; I have tried something similar in UIKit, but it seems the animator method is not there for UIView. So there's no "implicit" animation? 回答1: The iPhone supports implicit animation, though it does not use an animator object, it is built directly into UIView. Try this instead: [UIView beginAnimations:nil context:nil]; [aView setFrame:NSMakeRect(100.0,100.0,300.0,300.0)]; [UIView commitAnimations]; The exact

Delay with touch events

荒凉一梦 提交于 2019-12-01 09:37:50
问题 We have an app in AppStore Bust~A~Spook we had an issue with. When you tap the screen we use CALayer to find the position of all the views during their animation and if you hit one we start a die sequence. However, there is a noticeable delay, it appears as if the touches are buffered and we we receive the event to late. Is there a way to poll or any better way to respond to touches to avoid this lag time? This is in a UIView not a UIScrollView 回答1: Are you using a UIScrollView to host all

How to use UIBezierPath with CoreAnimation?

删除回忆录丶 提交于 2019-12-01 09:26:15
问题 I am using this code to remove animate my UIView to the delete button on delete button press. Here's the code : UIBezierPath *movePath = [UIBezierPath bezierPath]; [movePath moveToPoint:icon.center]; [movePath addQuadCurveToPoint:senderView.center controlPoint:CGPointMake(senderView.center.x, icon.center.y)]; CAKeyframeAnimation *moveAnim = [CAKeyframeAnimation animationWithKeyPath:@"position"]; moveAnim.path = movePath.CGPath; moveAnim.removedOnCompletion = YES; CABasicAnimation *scaleAnim =

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

UIImage as CAShapeLayer contents

喜你入骨 提交于 2019-12-01 08:59:09
If I create a CAShapeLayer with just a background color it shows up, but if i set the content to an image, nothing shows. CAShapeLayer* leftDot = [CAShapeLayer layer]; leftDot.opacity = 1.0; leftDot.frame = CGRectMake(leftRef.CGPointValue.x, leftRef.CGPointValue.y, 2 * radius, 2 * radius); leftDot.position = CGPointMake(leftRef.CGPointValue.x + 4, leftRef.CGPointValue.y + 4); leftDot.cornerRadius = radius; [leftDot setContents:[UIImage imageNamed: @"glow.png"]]; [self.layer addSublayer: leftDot]; CAShapeLayer doesn't work that way. You would create a normal CALayer with the image as its