core-animation

Synchronising image, text, and positioning with CoreAnimation

≡放荡痞女 提交于 2019-12-08 07:17:06
问题 I am a bit of a beginner with animations and have been experimenting with CoreAnimation for a couple of days. Feel free to warn me if this question does not make sense, but I'm trying to achieve the following. I have three objects: one should be an image, moving according to a given pattern one should be an UIImage that swaps two images one should be a text (CATextLayer?) whose content changes The three actions should happen in sync. As an example, think about a programme showing a sinusoid

Limit effect of UIPercentDrivenInteractiveTransition to topmost view

倖福魔咒の 提交于 2019-12-08 07:16:48
问题 Is there a way to limit the effect of UIPercentDrivenInteractiveTransition to only the topmost view in a view hierarchy? Specifically: as explained here and here the interactive transition sets the container view layer's speed to 0 and then manipulates the timeOffset to scrub through the transition. If for example I have an activity indicator in that containing view, the interactive transition also scrubs through the activity indicator's spin animation. It stops spinning and appears to "roll"

replaceSublayer example

浪子不回头ぞ 提交于 2019-12-08 07:00:46
问题 I have the following code and I can't seem to get it to work. First I create a view with a layer. UIView *view = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 100)] autorelease]; CAGradientLayer *gradient = [CAGradientLayer layer]; gradient.frame = view.bounds; gradient.colors = [NSArray arrayWithObjects:(id)[[UIColor blackColor] CGColor], (id)[[UIColor whiteColor] CGColor], nil]; [view.layer insertSublayer:gradient atIndex:0]; Next I need to replace that layer. I have tried the

How do I calculate the height of the bottom edge when rotating a plane on the x-axis in 3d space?

喜夏-厌秋 提交于 2019-12-08 06:29:55
问题 In my iOS app, I have a view that I'm translating on the X axis in 3D space. The anchor point for the view is in the top center. If I rotate the view M_PI degrees, it will appear to go flat. I need X pixels between the bottom of the screen and the bottom edge of the rotated view (essentially, the bottom edge's height off the ground needs to be X px). How do I calculate this percentage of M_PI? Here's an example. In this case the view is 100px high, and I need to rotate it some percentage of M

UIView infinite loop Animation to call a method after every repeat cycle

流过昼夜 提交于 2019-12-08 06:27:56
问题 I am at my wits end trying to come up with a design pattern for this paradigm. I haven't had much luck on this site but at this stage I'll try anything. I am trying to implement a radar type animation and hence I am rotating a view 360 degrees to represent the radius rotating around the circle. I have placed points around this circle and am able to calculate the angle from the center of the circle using standard trig. As the radius sweeps around the circle, if it intersects with a point (eg

How to make a filling progress circle in iOS?

血红的双手。 提交于 2019-12-08 06:17:23
问题 I need to make a progress circle like this: I have created a CAShapeLayer for the circle, and animate its strokeEnd property like this: pieShape = CAShapeLayer() pieShape.path = UIBezierPath(arcCenter: CGPointMake(29, 29), radius: 27.0, startAngle: CGFloat(startAngle), endAngle: CGFloat(endAngle), clockwise: true).CGPath pieShape.fillColor = UIColor.clearColor().CGColor pieShape.strokeColor = UIColor.blackColor().CGColor pieShape.lineWidth = 4.0 self.layer.addSublayer(pieShape) let

Set UITableViewCell background color using a CALayer

拈花ヽ惹草 提交于 2019-12-08 06:09:35
问题 On iOS, I am adding a CALayer to a UITableViewCell's layer. This is my first time using CALayer, and it is simply supposed to change the background color of the table cell. My goal is (1) to learn how to use CALayer, and (2) to test using Instruments whether the drawing is faster than my current implementation, which slows down on CGContextFillRect. (Technical Q&A QA1708 was the catalyst for all this.) Current Implementation (works) - (void)drawRect:(CGRect)r { UIColor *myColor = [self

How to synchronize CALayer and UIView animations up and down a complex hierarchy

杀马特。学长 韩版系。学妹 提交于 2019-12-08 03:08:18
问题 See How to manage CALayer animations throughout a hierarchy for a follow-up question that is concerned just with how to synchronize parent-child layer animations. This is a design question concerning running dependent animations at different levels of the view hierarchy in response to animations up the hierarchy. I have a container controller that has any number of child controllers. The parent controller organizes this content on the screen and at various points needs to change the size and

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

坚强是说给别人听的谎言 提交于 2019-12-08 03:06:32
问题 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

Layer animations removed when switching apps

China☆狼群 提交于 2019-12-08 03:02:25
问题 (iOS 5.0) I have an CAKeyframeAnimation added to a view's layer with an infinite repeat count (a cursor blinking). However, when switching apps and coming back, the animation gets removed from the layer (or possibly the entire layer is replaced, I'm not sure). I tried re-adding them on viewDidLoad and viewWillAppear, but neither is called when switching apps. I did find there is a applicationWillEnterForeground: method in UIApplicationDelegate. I'm planning to use this but I have two