core-animation

Take a snapshot of a hidden UIView

纵饮孤独 提交于 2019-12-23 09:56:53
问题 I'm trying to take a snapshot of a hidden view but am running into several issues. If I try unhiding it quickly, taking a snapshot, and then rehiding it, I sometimes get a quick flicker on the screen that is pretty jarring. toCollectionViewCell.hidden = NO; UIView *toPlaceHolderSnapshot = [toCollectionViewCell resizableSnapshotViewFromRect:toCollectionViewCell.bounds afterScreenUpdates:YES withCapInsets:UIEdgeInsetsZero]; toCollectionViewCell.hidden = YES; I'm pretty sure the flicker is

CAKeyFrameAnimation not Linear for values greater than PI

我的未来我决定 提交于 2019-12-23 09:17:08
问题 I am having some trouble to understand why an animation isn't working like expected. What I am doing is this: Create a UIBezierPath with an arc to move a Label along this path and animate the paths stroke. //Start Point is -.pi /2 to let the Arc start at the top. //self.progress = Value between 0.0 and 1.0 let path : UIBezierPath = UIBezierPath.init(arcCenter: CGPoint.init(x: self.bounds.width * 0.5, y: self.bounds.height * 0.5), radius: self.bounds.width * 0.5, startAngle: -.pi / 2, endAngle

CALayer autoresizingMask not for iOS SDK?

会有一股神秘感。 提交于 2019-12-23 08:10:08
问题 I noticed, what CALayer, on iOS SDK haven't autoresizingMask property. I'm not sure what custom overloading of method "setFrame:" can work normally with animated sublayers autoresizing. Are there is an alternative without using UIView? 回答1: You can use layoutSublayers function of calayer. 回答2: If you do not want to subclass CALayer and added the layer to the layer of a UIView then you can override - (void)layoutSublayersOfLayer:(CALayer *)layer method of view. 来源: https://stackoverflow.com

Check if NSAnimationContext runAnimationGroup cancelled or succeeded

笑着哭i 提交于 2019-12-23 07:48:23
问题 I'm animating a view (by revealing it) after which I need to post a notification (once the animation completes). However the way the app's designed, there's another notification sent out when the view is hidden (via animation). So essentially I have a 'showView' and a 'hideView' method. Each do something like so: [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context) { [context setDuration: 0.25]; [[myView animator] setAlphaValue: 0]; } completionHandler:^{ // post notification

Check if NSAnimationContext runAnimationGroup cancelled or succeeded

删除回忆录丶 提交于 2019-12-23 07:48:12
问题 I'm animating a view (by revealing it) after which I need to post a notification (once the animation completes). However the way the app's designed, there's another notification sent out when the view is hidden (via animation). So essentially I have a 'showView' and a 'hideView' method. Each do something like so: [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context) { [context setDuration: 0.25]; [[myView animator] setAlphaValue: 0]; } completionHandler:^{ // post notification

The scope of a CATransaction block

≡放荡痞女 提交于 2019-12-23 05:11:57
问题 I have seen some code that removes a given layer from it's superlayer by doing the following: void RemoveImmediately(CALayer *layer) { [CATransaction flush]; [CATransaction begin]; [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; [layer removeFromSuperlayer]; [CATransaction commit]; } I have written a method that changes the position of a given layer in an animated way using CAKeyframeAnimation, which looks like this: - (void)animateMovingObject:(NXUIObject*

How to Draw a line pixel by pixel using objective C

别来无恙 提交于 2019-12-23 05:09:11
问题 I want to draw a line(on iphone) such that i can view each pixel being draw. I am currently calling the drawRect method using a timer. Following is the code where i am drawing a wave using the values from an array: static int i=0; int x = 10; int y = 0; int x2; int y2; - (void)drawRect:(CGRect)rect { // Drawing code. CGContextRef c = UIGraphicsGetCurrentContext(); CGFloat black[4] = {0.0f,0.0f,0.0f,1.0f}; CGContextSetStrokeColor(c, black); CGContextBeginPath(c); NSLog(@"fired..."); int ecg

poor performance using layer-backed NSOpenGLView

半城伤御伤魂 提交于 2019-12-23 04:47:27
问题 I'm updating my OS X app to use layer-backed views, so I can have Cocoa views on top of my OpenGL rendering (I haven't added any Cocoa views yet). Without layers, I get 60fps. With layers, less than 15fps. My iOS version, where everything is layer-backed, gets 60fps. I enabled layer backing thusly: I also had to set the layer's background color to black to avoid bad compositing (I use OpenGL blending, so the final alpha values in the buffer aren't correct for CA compositing). According to

How to improve performance of CALayer animations?

依然范特西╮ 提交于 2019-12-23 03:50:56
问题 while studying Core Animation, I've made a UIView category which makes a subview be broken into a lot of tiles and diffused. https://github.com/minorblend/HNTileDisappear However, when the number of tiles are not small FPS of animation drops steeply. Is there any way or idea to improve the performance of this kind of CALayer animation? 回答1: A few things come to mind: 1) set shouldRasterize to YES on your layers 2) don't use fractional values in frames if you can 3) make your layers opaque 4)

Deadlocks: How do you determine if a call may cause unsafe painting off of the main thread for iOS?

[亡魂溺海] 提交于 2019-12-23 02:54:25
问题 Drawing/painting should always be done on the GUI thread otherwise deadlocks can occur!... How do you determine if a call may cause unsafe painting off of the main thread for iOS? The problem is we get stacks like this which are not on the main thread... #19 0x02a788d2 in -[CALayer drawInContext:] #20 0x02a784b0 in backing_callback #21 0x02a77d52 in CABackingStoreUpdate #22 0x02a7701d in -[CALayer _display] #23 0x02a76ac7 in CALayerDisplayIfNeeded #24 0x02a689e1 in CA::Context::commit