core-animation

CALayer and CAAnimation's dynamic resolution of unimplemented property accessors

£可爱£侵袭症+ 提交于 2019-12-11 03:28:00
问题 I found that CALayer and CAAnimation don't only extend the NSKeyValueCoding protocol as described in Core Animation Extensions To Key-Value Coding, but also offer dynamic resolution for unimplemented property accessors. For example: @interface DotLayer : CALayer @property (nonatomic, retain) id dot; @end @implementation DotLayer @dynamic dot; @end Simply with a property declaration and stating it is @dynamic , I can access dot property without implementing its accessors: DotLayer *layer =

Reconciling CACurrentMediaTime() and deviceCurrentTime

人盡茶涼 提交于 2019-12-11 03:23:57
问题 I am trying to synchronize several CABasicAnimations with AVAudioPlayer . The issue I have is that CABasicAnimation uses CACurrentMediaTime() as a reference point when scheduling animations while AVAudioPlayer uses deviceCurrentTime . Also for the animations, CFTimeInterval is used, while for sound it's NSTimeInterval (not sure if they're "toll free bridged" like other CF and NS types). I'm finding that the reference points are different as well. Is there a way to ensure that the sounds and

CAShapeLayer detect touch during animation Swift

三世轮回 提交于 2019-12-11 03:17:59
问题 I can detect a touch of a CAShapeLayer like this (touchesEnded): let touchLocation : CGPoint = (touch as! UITouch).locationInView(self.view) for shape in shapes{ if CGPathContainsPoint(shape.path, nil, touchLocation, false){ print("Layer touch") } } And I can animate the path of a CAShapeLayer like this: let newShapePath = UIBezierPath(arcCenter: toPoint, radius: 20, startAngle: CGFloat(0), endAngle: CGFloat(M_PI * 2), clockwise: true).CGPath // animate the `path` let animation =

Core animation stops when the Master of the split viewcontroller hide (in portrait mode)?

假如想象 提交于 2019-12-11 01:56:25
问题 I applied the blinking animation to the contentView of the tableViewcell for a table in First viewController of the splitviewController. My problem is, the animation stops when I hide the FirstViewcontroller with presentsWithGesture property of splitViewController I have subclassed UItableViewCell and I add animation while setting a property and I added the animation to the contentView of cell like below -(void)setProperty:(Property *)aProperty { _property=aProperty; [self.contentView

Core Animation with contentsRect jerkiness

左心房为你撑大大i 提交于 2019-12-11 01:13:48
问题 in my (puzzle) game the pieces are drawn on-screen using a CALayer for each piece. There are 48 pieces (in an 8x6 grid) with each piece being 48x48 pixels. I'm not sure if this is just too many layers, but if this isn't the best solution I don't know what is, because redrawing the whole display using Quartz2D every frame doesn't seem like it would be any faster. Anyway, the images for the pieces come from one big PNG file that has 24 frames of animation for 10 different states (so measures

Zoom Core Graphics in UIScrollView

时间秒杀一切 提交于 2019-12-11 00:47:17
问题 I was wondering which would be the best way to scale my Core Graphics drawings as I zoomed in using a UIView subclass within a UIScrollView. Currently when I zoom in, the drawing becomes slightly fuzzy - I know this is correct functioning, I just want to know how developers override it to keep the image sharp... Thanks! (P.s. I have heard about using Core Animation, but I don't know where to start on that huge library with scary names haha!) 回答1: The simplest way is to use supersampling.

Why does UIView:animateWithDuration complete immediately?

ぐ巨炮叔叔 提交于 2019-12-11 00:32:52
问题 I have a subclass of MKPointAnnotation with the following method which I run on iOS 4: - (void)animate { [UIView animateWithDuration: 3.0 delay:1.0 options:UIViewAnimationOptionAllowUserInteraction animations:^{ CLLocationCoordinate2D loc = CLLocationCoordinate2DMake([self coordinate].latitude + 0.001, [self coordinate].longitude + 0.001); [self setCoordinate:loc]; } completion:^(BOOL finished) { NSLog(@"Is completed"); }]; } It is called by clicking a UIBarButtonItem . I expect to see the my

How to know when UIView animations have all completed

你。 提交于 2019-12-10 21:23:39
问题 A custom view I created is being animated by its container - in my view I update portions of the subviews with other animations (for instance a UICOllectionView) I see that this is throwing errors *** Assertion failure in -[UICollectionView _endItemAnimations Digging around I see that my view has animations attached to it: <GeneratorView: 0x15b45950; frame = (0 0; 320 199); animations = { position=<CABasicAnimation: 0x145540a0>; }; layer = <CALayer: 0x15b49410>> So now before performing

CALayer - backgroundColor flipped?

徘徊边缘 提交于 2019-12-10 20:25:39
问题 I'm creating a CALayer like this: UIColor *color = [UIColor colorWithPatternImage:[UIImage imageNamed:@"MyPattern.png"]]; backgroundLayer = [[CALayer alloc] init]; [backgroundLayer setBackgroundColor:[color CGColor]]; [[self layer] addSublayer:backgroundLayer]; For some reason, the pattern is drawn upside down. I've already tried setting geometryFlipped and applying sublayer transforms, but it doesn't work. 回答1: Using [backgroundLayer setTransform:CATransform3DMakeScale(1.0, -1.0, 1.0)];

UIKit Dynamics: recognize rounded Shapes and Boundaries

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-10 19:27:46
问题 i am writing an App where i use UIKit Dynamics to simulate the interactions of different circles with one another. I create my circles with the following code: self = [super initWithFrame:CGRectMake(location.x - radius/2.0, location.y - radius/2, radius, radius)]; if (self) { [self.layer setCornerRadius: radius /2.0f]; self.clipsToBounds = YES; self.layer.masksToBounds = YES; self.backgroundColor = color; self.userInteractionEnabled = NO; } return self; where location represents the desired