calayer

Resume CABasicAnimation using negative speed?

邮差的信 提交于 2021-02-19 02:55:20
问题 I resume my CABasicAnimation with the following code: CFTimeInterval pausedtime = layer.timeOffset; layer.speed = 1.0; layer.timeOffset = 0.0; layer.beginTime = [layer convertTime:CACurrentMediaTime() toLayer:nil] - pausedTime; which is pretty straightforward. At the very end of this article the author states that with negative speed value animation reverses. I can't understand what timeOffset and beginTime should look like in this case? P.S. I am aware that I can reverse animation by

UICollectionView Cell Shadow

孤者浪人 提交于 2021-02-17 19:47:10
问题 I am trying to add shadow to my custom UICollectionViewCell , This is the code I am using in my custom collection view cell class: self.layer.shadowOffset = CGSizeMake(1, 0); self.layer.shadowColor = [[UIColor blackColor] CGColor]; self.layer.shadowRadius = 5; self.layer.shadowOpacity = .25; This is giving shadow to the components of the collection view cell. 回答1: Don't forget to add these 2 lines self.clipsToBounds = false self.layer.masksToBounds = false 回答2: Swift 4.2 and xcode 10 here's

UICollectionView Cell Shadow

狂风中的少年 提交于 2021-02-17 19:45:08
问题 I am trying to add shadow to my custom UICollectionViewCell , This is the code I am using in my custom collection view cell class: self.layer.shadowOffset = CGSizeMake(1, 0); self.layer.shadowColor = [[UIColor blackColor] CGColor]; self.layer.shadowRadius = 5; self.layer.shadowOpacity = .25; This is giving shadow to the components of the collection view cell. 回答1: Don't forget to add these 2 lines self.clipsToBounds = false self.layer.masksToBounds = false 回答2: Swift 4.2 and xcode 10 here's

UIView.layer.presentationLayer returns final value (rather than current value)

我们两清 提交于 2021-02-08 10:53:24
问题 Here's some relevant code inside a UIView subclass : - (void) doMyCoolAnimation { CABasicAnimation* anim = [CABasicAnimation animationWithKeyPath:@"position.x"]; anim.duration = 4; [self.layer setValue:@200 forKeyPath:anim.keyPath]; [self.layer addAnimation:anim forKey:nil]; } - (CGFloat) currentX { CALayer* presLayer = self.layer.presentationLayer; return presLayer.position.x; } When I use [self currentX] while the animation is running, I get 200 (the end value) rather than a value between 0

UIView.layer.presentationLayer returns final value (rather than current value)

≯℡__Kan透↙ 提交于 2021-02-08 10:52:46
问题 Here's some relevant code inside a UIView subclass : - (void) doMyCoolAnimation { CABasicAnimation* anim = [CABasicAnimation animationWithKeyPath:@"position.x"]; anim.duration = 4; [self.layer setValue:@200 forKeyPath:anim.keyPath]; [self.layer addAnimation:anim forKey:nil]; } - (CGFloat) currentX { CALayer* presLayer = self.layer.presentationLayer; return presLayer.position.x; } When I use [self currentX] while the animation is running, I get 200 (the end value) rather than a value between 0

Draw concentric circle using UIBezierPath

青春壹個敷衍的年華 提交于 2021-02-08 05:49:12
问题 I am trying to draw a concentric circle using UIBezierPath the expected result as in this . but what I am actually getting is different like . I have tried to make two different circles with different diameter and fill the smaller one. let path = UIBezierPath(ovalIn: CGRect(x: position.x - diameter / 2, y: position.y - diameter / 2, width: diameter, height: diameter)) let path2 = UIBezierPath(ovalIn: CGRect(x: position.x - diameter / 2 + 2, y: position.y - diameter / 2 + 2, width: diameter -

Animating CALayer shadow simultaneously as UITableviewCell height animates

Deadly 提交于 2021-02-07 03:52:22
问题 I have a UITableView that I am attempting to expand and collapse using its beginUpdates and endUpdates methods and have a drop shadow displayed as that's happening. In my custom UITableViewCell, I have a layer which I create a shadow for in layoutSubviews : self.shadowLayer.shadowColor = self.shadowColor.CGColor; self.shadowLayer.shadowOffset = CGSizeMake(self.shadowOffsetWidth, self.shadowOffsetHeight); self.shadowLayer.shadowOpacity = self.shadowOpacity; self.shadowLayer.masksToBounds = NO;

Animating CALayer shadow simultaneously as UITableviewCell height animates

前提是你 提交于 2021-02-07 03:48:13
问题 I have a UITableView that I am attempting to expand and collapse using its beginUpdates and endUpdates methods and have a drop shadow displayed as that's happening. In my custom UITableViewCell, I have a layer which I create a shadow for in layoutSubviews : self.shadowLayer.shadowColor = self.shadowColor.CGColor; self.shadowLayer.shadowOffset = CGSizeMake(self.shadowOffsetWidth, self.shadowOffsetHeight); self.shadowLayer.shadowOpacity = self.shadowOpacity; self.shadowLayer.masksToBounds = NO;

CALayer frame origin.y is flipped, 0 is at the bottom?

99封情书 提交于 2021-02-07 03:09:36
问题 When I Add a set the fram on a CALayer the origin.y is reversed, 0 is at the bottom of it super layer and increasing origin.y moves it up in its super layer. Is there something I did to cause this to be flipped? I would expect origin.y=0 to be the top, not the bottom. Thanks, 回答1: You can flip the coordinate system to behave like iOS like this... layer.sublayerTransform = CATransform3DMakeScale(1.0f, -1.0f, 1.0f); 回答2: my two cents for UIViewController and swift: override func viewDidLoad() {

Smoothly rotate and change size of UIView with shadow

拟墨画扇 提交于 2021-02-05 20:28:28
问题 I have a UIView with a shadow and a UIImageView subview. I want to resize the view when the iPad is rotated and I'm trying to do this in the willRotateToInterfaceOrientation callback. If I set the shadow on the UIView in the basic way the rotation is very choppy; so I'd like some suggestions from others on how to set the shadow setting layer.shadowPath. I have tried animating the frame size change using [UIView animateWithDuration:animations] and setting the new shadowPath in the same block,