core-animation

iPhone, How do I rotate an UIImageView around a point using Core Animation and CATransform3D?

天大地大妈咪最大 提交于 2019-12-04 16:24:01
This is what I want to do: (1) (2) | / | / | / | / |/ * (3) I want to move an UIImageView represented by a clock pin (width:9px, height 73px) from position (1) to position (2) around point (3) which is one end of the image. I tried to set the anchorpoint to (0,0) or to set the image center to point (517,177) which is the *(3) location on the iPad screen, but I had no success: My degreeToRadians macro is defined in the following way: #define degreesToRadian(x) (M_PI * (x) / 180.0) /* kmPointer is the UIImageView */ NSValue *value = nil; CABasicAnimation *animation = nil; CATransform3D transform

Animation CAShapeLayer

て烟熏妆下的殇ゞ 提交于 2019-12-04 15:59:10
I draw a graph with this code: CAShapeLayer *curentGraph = [CAShapeLayer new]; CGMutablePathRef linePath = CGPathCreateMutable(); curentGraph.lineWidth = 3.0f; curentGraph.fillColor = [[UIColor clearColor] CGColor]; curentGraph.strokeColor = [colorGraph CGColor]; for (NSValue *value in arrOfPoints) { CGPoint pt = [value CGPointValue]; CGPathAddLineToPoint(linePath, NULL, pt.x,pt.y); }; curentGraph.path = linePath;CGPathRelease(linePath); [self.layer addSublayer:curentGraph]; and it looks like this But I have a problem. I need to animate the graph as it appears. Every point should move up from

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

烂漫一生 提交于 2019-12-04 14:59:09
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 single frame flash of the final frame of the transition animation and then the animation plays smoothly.

How do you override UIView's +(id)layer; class method?

眉间皱痕 提交于 2019-12-04 14:34:49
问题 I read in the documentation that a UIView's 'layer' property is read only and that you must override UIView's + (id)layer; class method to access the layer's styling properties. Are there any examples of overriding this method to return a layer/view with styling properties already applied? 回答1: If you just want to set properties like backgroundColor, opacity, etc. on the default CALayer that's assigned to the UIView, you can set those on the UIView's layer at any time using something like the

Creating a movie file of a animation with avassetwriter

北慕城南 提交于 2019-12-04 14:28:02
问题 I have a animation created using normal core animation methods. If there any way to create a movie file using avassetwriter? Ive seen other questions which show the how to use avassetwriter to create a movie using images, but i would like to create a movie using a animation created with core animation. Thank in advance 回答1: Run a timer (or whatever) to periodically convert the animation's CALayer to a UIImage (see here), then write that image to the AVAssetWriter as seen in the other examples

Slide UITableViewCell

假装没事ソ 提交于 2019-12-04 13:57:09
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.frame.size.width, cell.layer.position.y)]; CABasicAnimation *animation = [CABasicAnimation

On iOS, setNeedsDisplay really doesn't cause drawRect to be called… unless CALayer's display or drawInContext finally calls drawRect?

可紊 提交于 2019-12-04 13:54:18
问题 I don't really understand how CALayer's display and drawInContext relate to drawRect in the view. If I have an NSTimer that sets the [self.view setNeedsDisplay] every 1 second, then drawRect is called every 1 second, as shown by an NSLog statement inside of drawRect . But if I subclass a CALayer and use that for the view, if I make the display method empty, then now drawRect is never called. Update: But display is called every 1 second, as shown by an NSLog statement. If I remove that empty

CoreAnimation, moving UIImageView with animating shadow in iOS 5 Xcode 4

烂漫一生 提交于 2019-12-04 13:42:38
问题 I am trying to add a (fake)3d like effect for an image (UIImageView moving from point A to B, during this movement I want at point C=(A+B)/2 for it to have the biggest shadow size (or larger shadow offset), so it looks like it is going up and down again. when I try to even change the shadow size, it is not animating. could you help me how to edit this code: NSValue *pointB = [NSValue valueWithCGPoint:CGPointMake(CGRectGetMinX(imageView.frame)+50, CGRectGetMinY(imageView.frame)+50)]; [self

How Can I Animate the Size of A UICollectionViewCell on Scroll so the middle one is largest?

大兔子大兔子 提交于 2019-12-04 13:30:33
I have a UICollectionView that shows several rows with one, full-width column (looks like a UITableView) What I'd like to achieve is something similar to this: ... where the middle cell has a much greater height. As the user scrolls up and down, the cells before and after the middle cell animate back to the default height for the given cell. Can somebody outline how I should approach this problem? I use this Swift 3 code in my horizontal UICollectionView . func scrollViewDidScroll(_ scrollView: UIScrollView) { let centerX = scrollView.contentOffset.x + scrollView.frame.size.width/2 for cell in

3D Cube Problem! Part 1

…衆ロ難τιáo~ 提交于 2019-12-04 13:20:35
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 wondering how I got the degree sign then here is the trick Option + K its because you are not changing