core-animation

Drawing particles

别等时光非礼了梦想. 提交于 2019-12-22 04:18:22
问题 One part of my app shows a landscape, but it's kinda boring as of now. Therefore, I'm planning to animate some particles over the screen (think of something like tiny wings - http://www.youtube.com/watch?v=DpmcX-rWGfs). However, i have not yet found any built-in particle system; How can i do this memory-efficiently? I've already implemented my own animation system for some clouds animating over the landscape using CADisplayLink, and it's kind of sluggish (though i hope to make it faster soon)

CATextLayer wrapped sizeToFit?

六月ゝ 毕业季﹏ 提交于 2019-12-22 04:17:09
问题 If I set textLayer.wrapped = YES , how do I resize textLayer to contain the wrapped text? I.e., how do I get the new height of the textLayer ? Basically, I want something like -[UILabel sizeToFit] . 回答1: The first thing you need to do is get the size of the text. Thankfully, the NSString UIKit Additions Reference offers a method to do exactly that: - (CGSize)sizeWithFont:(UIFont *)font constrainedToSize:(CGSize)size lineBreakMode:(UILineBreakMode)lineBreakMode That will give you a CGSize that

Hide UINavBar and UITabBar at the same time with animation

徘徊边缘 提交于 2019-12-22 04:04:15
问题 Edit : I awarded the bounty to john since he put a lot of effort into his answer, and would get it anyways, but there's still no working solution. I am still looking for an answer, if someone knows how to do this it'd be greatly appreciated. I want to add a "maximize" button to my app that hides the navigation and tab bar. The navbar and tabbar should slide in/out smoothly, and the inner/content view should also expand and shrink at the same rate as the navbar and tabbar. I used [self

How do I convert 3D OpenGL matrix transforms to CoreAnimation CATransform3Ds?

可紊 提交于 2019-12-21 23:33:32
问题 Picture an OpenGL ES 1.1 rendering surface with a transparent CALayer of the same frame and bounds directly above it. Objects in the OpenGL scene are transformed (translated and rotated) using a 4x4 matrix. The overlayed CALayer transforms sublayers with a CATransform3D (which happens to be a 4x4 matrix, identical to ones used for OpenGL transforms). The OpenGL matrices transform the scene objects in exactly the manner I would like them to. I would then like to take the same matrix transform

Making OpenGL coexist with Core Animation on macOS

人盡茶涼 提交于 2019-12-21 23:25:04
问题 Is it possible for a layer-backed NSView to correctly do OpenGL rendering in drawRect: , or is it necessary to use NSOpenGLLayer / CAOpenGLLayer ? Until recently, I haven't needed to worry about that, I just used a non-layer-backed view. But as stated in the AppKit release notes for 10.14: Windows in apps linked against the macOS 10.14 SDK are displayed using Core Animation when the app is running in macOS 10.14. To show how this breaks my rendering, I put together a sample app, with code

How to animate drawing in Swift, but also change a UIImageView's scale?

余生颓废 提交于 2019-12-21 23:18:42
问题 I'd like to animate a drawing sequence. My code draws a spiral into a UIImageView.image. The sequence changes the image contents, but also changes the scale of the surrounding UIImageView. The code is parameterized for the number of revolutions of the spiral: func drawSpiral(rotations:Double) { let scale = scaleFactor(rotations) // do some math to figure the best scale UIGraphicsBeginImageContextWithOptions(mainImageView.bounds.size, false, 0.0) let context = UIGraphicsGetCurrentContext()!

UIViewController Containment with animation like Google+

半世苍凉 提交于 2019-12-21 22:26:18
问题 The best way to understand what I'm trying to explain is to open Google+ app and tap anywhere in background of a post displayed in the main stream of posts. When you tap it, the entire post moves itself at the center of the screen with a nice animation and it loads the post's comments below it. I think this is a common UIViewController containment scenario, where one UIViewController is inside another. But how the post can moves it animately and "transfering" itself inside the contained view

iOS 10 UILabels -> 1 UIView -> Loop through with Animation

雨燕双飞 提交于 2019-12-21 21:14:28
问题 I have 10 UILabels , maybe some UIImageViews . I want to display all these in 1 UIView with smooth FadeOut & FadeIn transition, one after the other. I know putting UIView animations in a for-loop will not work as animations are done asynchronous & will not give proper effect. So the way normally I would do this is to chain UIView animation together. i.e. after one elements animation is complete begin the next one. For 3-4 elements the code looks ok. Like so - [UIView animateWithDuration:0.25

CATransition showing a single frame from the end of the transition before the animation starts

十年热恋 提交于 2019-12-21 20:37:28
问题 I am using some code which was originally taken from the Apple sample ViewTransitions to swap two views with each other. CATransition *animation = [CATransition animation]; [animation setDelegate:self]; [animation setType:kCATransitionFade]; [animation setDuration:0.3f]; [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]]; [[container layer] addAnimation:animation forKey:@"swap"]; When my transition executes on the devlice, I sometimes get a

Can you animate gradients using Quartz in an iPhone?

人走茶凉 提交于 2019-12-21 20:27:53
问题 I am new to iPhone development and am currently toying with recreating a charting tool I developed for Silverlight. Currently I'm using a gradient to 'fill' a rectangle representing a bar within a chart. Is it possible to animate this gradient so it changes colour when a user touches the bar within the chart. I have looked through the Core Animation guides provided by Apple but cannot see a property which targets gradients. I suppose I could use a transition to fade between two rects, one of