core-animation

How can I restart my block-based animation when the application comes to the foreground?

只愿长相守 提交于 2019-12-09 13:15:59
问题 I have the following block-based animation: [UIView animateWithDuration:0.5f delay:0.0f options:UIViewAnimationOptionRepeat|UIViewAnimationOptionAutoreverse|UIViewAnimationOptionAllowUserInteraction|UIViewAnimationOptionCurveEaseInOut animations:^{ [view.layer setTransform:CATransform3DMakeScale(1.3f, 1.3f, 1.0f)]; NSLog(@"animating"); }completion:^(BOOL finished){ NSLog(@"Completed"); }]; When the app returns from being in the background, the completion block is called, and my animations don

iPhone flip right button (like iTunes)

冷暖自知 提交于 2019-12-09 12:55:42
问题 I'm trying to flip between two views. That's easy, the code is below, but I also want to simultaneously flip the button used to perform the flip. You can see this behavior in the iPod application when you're playing a track; tapping the flip button flips between the cover art and the track listing, but it flips the button at the same time. This is a page on the navigation controller, and the button I want to flip is the rightBarButtonItem . Here's the code I have so far. This flips the view,

Changing cornerRadius using Core Animation

只愿长相守 提交于 2019-12-09 11:10:39
问题 I am trying to change the corner radius of a button (OpenNoteVisible.layer) in the following way: CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"cornerRadius"]; animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]; animation.fromValue = [NSNumber numberWithFloat:10.0f]; animation.toValue = [NSNumber numberWithFloat:0.0f]; animation.duration = 1.0; [animation.layer setCornerRadius:140.0]; [OpenNoteVisible.layer addAnimation

Rotating a CALayer 90 degrees?

两盒软妹~` 提交于 2019-12-09 07:35:13
问题 How do I rotate a CALayer 90 degrees? I need to rotate everything include sublayers and the coordinate system. 回答1: If I'm animating it I use something like this in my apps: - (NSObject *) defineZRotation { // Define rotation on z axis float degreesVariance = 90; // object will always take shortest path, so that // a rotation of less than 180 deg will move clockwise, and more than will move counterclockwise float radiansToRotate = DegreesToRadians( degreesVariance ); CATransform3D zRotation;

How do I use CALayer with the iPhone?

帅比萌擦擦* 提交于 2019-12-09 07:23:48
问题 Currently, I have a UIView subclass that "stamps" a single 2px by 2px CGLayerRef across the screen, up to 160 x 240 times. I currently animate this by moving the UIView "up" the screen 2 pixels (actually, a UIImageView) and then drawing the next "row". Would using multiple CALayer layers speed up performance of rendering this animation? Are there tutorials, sample applications or code snippets for use of CALayer with the iPhone SDK? The reason I ask is that most of the code snippets I find

Circle to rectangle transformation animation

僤鯓⒐⒋嵵緔 提交于 2019-12-09 07:16:28
问题 I am very new to iOS and I need to do following animation: Transformation of the circle to rectangle should be smooth, but in above animation it's not very smooth. What I did is create a circle and a rectangle using following code in this tutorial: Circle : class OvalLayer: CAShapeLayer { let animationDuration: CFTimeInterval = 0.3 override init() { super.init() fillColor = Colors.red.CGColor path = ovalPathSmall.CGPath } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has

Animating images using CAAnimation

别说谁变了你拦得住时间么 提交于 2019-12-09 07:04:51
问题 Is it possible to implement animating sequence of images using CAAnimation? And i dont want to use UIImageView... I need Something similar to UIImageView where we can set imageView.animationImages and calling startAnimation... but using CAAnimation 回答1: CAKeyframeAnimation *animationSequence = [CAKeyframeAnimation animationWithKeyPath: @"contents"]; animationSequence.calculationMode = kCAAnimationLinear; animationSequence.autoreverses = YES; animationSequence.duration =

layer hit test only returning layer when bottom half of layer is touched

孤人 提交于 2019-12-09 06:44:56
问题 I have a sublayer on a layer-backed view. The sublayer's contents are set to an Image Ref and is a 25x25 rect. I perform a hit test on the super layer when the touchesBegan and touchesMoved methods are invoked. The hit test method does, in fact, return the sublayer if it is touched, BUT only if the bottom half of the image is touched. If the top half of the image is touched, it returns the superlayer instead. I do know the iPhone OS compensates for the tendancy of user touches to be lower

Getting started creating custom view transitions

╄→尐↘猪︶ㄣ 提交于 2019-12-09 04:46:39
问题 I'm looking for tutorials on creating custom view transitions. In particular, transitions that involve elements other than just the UIViews being affected, such as playing an animation over the transition as it is happening or modifying a screenshot of the UIView being transitioned out. I don't mean implementing the basic set of transitions (slide, fade, etc) for which there's plenty of examples on Apple's site. I'm talking about adding video/sound/additional animation while wrapping it all

How do I speed up iOS transitions and segues?

泪湿孤枕 提交于 2019-12-09 01:47:05
问题 Is it possible to set a property application-wide to double the speed of transitions within an iOS app? 回答1: Application-wide? Try setting the speed property on the backing layer for your view controller's content views. speed=2 would be double-speed. You could probably set this in the viewDidLoad method for all your view controllers. You might also be able to create a custom subclass of UIWindow, and have that window object set the speed property on it's view layer to 2.0 in a bottleneck