core-animation

Troubles with UIView, animateWithDuration and beginFromCurrentState

自古美人都是妖i 提交于 2019-12-06 08:43:28
I have a custom view that has to track the user's location. I put the following code in touchesBegan , as well as in touchesMoved : [UIView animateWithDuration:0.2 delay:0.0 options:UIViewAnimationOptionBeginFromCurrentState animations:^{ cursorView.center = locationOfTouch; } completion:^(BOOL finished){}]; It seems fairly straightforward to me. I'd expect the view to always animate to the user's current location, even if that location is changed and the view is still animating (because of the beginFromCurrentState option). Yet, each animation finishes completely. They don't 'transition' to

UIView animation VS core animation

拥有回忆 提交于 2019-12-06 08:36:57
问题 I'm trying to animate a view sliding into view and bouncing once it hits the side of the screen. A basic example of the slide I'm doing is as follows: // The view is added with a rect making it off screen. [UIView beginAnimations:nil context:NULL]; [UIView setAnimationBeginsFromCurrentState:YES]; [UIView setAnimationDuration:0.07]; [UIView setAnimationCurve:UIViewAnimationCurveLinear]; [UIView setAnimationDelegate:self]; [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished

Make CVDisplayLink + Automatic Reference Counting play well together

天大地大妈咪最大 提交于 2019-12-06 08:31:33
问题 I recently switched from using NSTimer to CVDisplayLink to redraw my OpenGL animation, but i've got a little problem making it work with ARC switched on: /* * This is the renderer output callback function. */ static CVReturn displayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeStamp* now, const CVTimeStamp* outputTime, CVOptionFlags flagsIn, CVOptionFlags* flagsOut, void* displayLinkContext) { // now is the time to render the scene [((__bridge BDOpenGLView*)displayLinkContext)

Animating a UIImageView tint

馋奶兔 提交于 2019-12-06 08:23:54
问题 Similar to this previous question, I want to apply an arbitrarly-coloured tint to an arbitrary image (a UIImageView ). However, I want the tint to fade away over N seconds of time, to have a "pulse" effect. I'll be triggering the pulse every M seconds. While I think I could rig up a naive solution using an NSTimer to change the tint, I think I can probably use some of the Core Animation framework to have a much more elegant (and efficient) solution. However, I'm not very familiar with Core

How can I make a UI element added via -addSublayer: respond to touch events?

最后都变了- 提交于 2019-12-06 08:16:05
The following is code that I use to add a UIButton to a layer via -addSublayer : CAGradientLayer * tile = [[tile alloc] init]; UIButton *XImageButton = [[UIButton alloc]init]; XImageButton.frame= CGRectMake(kXButtonlocX, kXButtonlocY, kXButtonHeight,kXButtonWidth ); [XImageButton setTitle:@"xbutton" forState:UIControlStateNormal]; [XImageButton addTarget:nil action:@selector(XbuttonTouchEvent) forControlEvents:UIControlEventTouchUpInside]; [tile addSublayer:XImageButton.layer]; The XImageButton isn't responding to touch events. How can I fix this so that it does respond? You can't. You'll have

Flip View Animation Not Working

自作多情 提交于 2019-12-06 08:12:04
I am working on an iPad app that presents a question to the user in a view. When they answer the question, I would like the view to transition to another view that contains the next question. To make it look all fancy, I am trying to add a curl transition to it but the code I wrote does not work can I can't see to find the problem. It does show the correct view but there is no transition animation. What's with that? Here is the method I use to transition: - (void)pageChangedTo:(NSInteger)page { if ( (page == currentQuestionNumber) || (page > ( [self.allQuestions count] - 1 ) ) || (page < 0) )

Smooth horizontal flip using CATransform3DMakeRotation

拥有回忆 提交于 2019-12-06 08:00:52
问题 I have set up the following animation to rotate between views of different sizes. The midpoint of the animation seems to have a flicker as the new, taller view comes into view. Is there anything I can do to smoothen the transition. newView.layer.transform = CATransform3DMakeRotation(M_PI_2, 0.0, 1.0, 0.0); [UIView animateWithDuration:0.5 delay:0 options:UIViewAnimationOptionCurveLinear animations:^{oldView.layer.transform = CATransform3DMakeRotation(M_PI_2, 0.0, -1.0, 0.0);} completion:^(BOOL

Repeating UIAnimation block, and a way to stop it again

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-06 07:56:53
问题 I wanted to do a small loader animation to put in my app. I have done repeating animations before with CGAnimations without problems, this time I was going for the block approach. I am doing a small test but can make the following code repeat: - (void) startLoading { __block int count = 0; [UIView animateWithDuration:0.4 delay: 0.0 options: UIViewAnimationOptionRepeat animations:^{ count++; } completion:^(BOOL finished){ if (count > 5) count = 0; NSLog(@"%d", count); }]; } - (void)

3D Cube Problem! Part 1

廉价感情. 提交于 2019-12-06 07:33:28
问题 I have created a 3D cube in iphone using CALayer's . Now I wanted to rotate that cube( CALayer ) at 90˚ when user double taps on it. I was able to rotate that cube( CALayer ) to 90˚ once but when I double tap the cube( CALayer ) is not rotating. Here is the code that I used to rotate the cube( CALayer ) CATransform3D x = CATransform3DRotate(currentLayer.sublayerTransform, M_PI / 2, 0, 0, 1); currentLayer.transform = x; Can anyone help in this. What I'm doing wrong. PS. For the people who are

Slide UITableViewCell

一个人想着一个人 提交于 2019-12-06 07:08:03
问题 My goal is to have a UITableViewCell slide off one side of the screen (like in Twitter) and then slide back on from the other side. I'm able to make the cell slide off the screen to the right, but I can't seem to figure out how to get it to slide back onto the screen from the left right after. Here's my code to slide it off to the right: UITableViewCell *cell = [self cellForRowAtIndexPath:indexPath]; [cell.layer setAnchorPoint:CGPointMake(0, 0.5)]; [cell.layer setPosition:CGPointMake(cell