所以我试图用UIView做一个缩小/成长的圈子.我正在使用UIView.animateWithDuration ...(blah blah blah)用于视图的框架,而CABasicAnimation用于为视图的(图层)角半径设置动画.两个动画正确的持续时间和结束在正确的,圆形的值(转角半径= 1/2宽度).问题是在动画期间,CABasicAnimation和UIView.animateWithDuration似乎有不同的动画曲线.如何实现正确的圆形动画.
如果答案是对农场膨胀使用CABAsicAnimation,请解释如何做到这一点.
谢谢!
此代码是UIView的扩展.
//This is how it's being used to shrink the circle:
circleview.growByPixles(-10, seconds: 0.3, completion: {})
circleview.setCornerRadius(radius:(circleview.bounds.size.width - 10) / 2 seconds: 0.3)
//////
func morphToFrame(frame: CGRect, seconds: Double, completion: () -> ()) {
UIView.animateWithDuration(seconds,
animations: {
self.frame = frame
},
completion: { _ in
completion()
})
}
//negative integers shrink
func growByPixels(pixels: CGFloat, seconds: Double, completion: () -> ()) {
var f:CGRect = self.frame
var newFrame:CGRect = …Run Code Online (Sandbox Code Playgroud) 我正在尝试移动两个视图的帧的简单动画.基本上隐藏广告直到加载,然后从底部向上移动框架,以及从底部开始的视图,然后在广告向上推动时向上移动.开始和结束位置都是正确的,但我不认为它是动画的.它是否正确?谢谢.
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"frame"];
animation.duration = 1.0;
CGRect adFrame = CGRectMake(self.adBanner.frame.origin.x, self.adBanner.frame.origin.y - self.adBanner.frame.size.height, self.adBanner.frame.size.width, self.adBanner.frame.size.height);
self.adBanner.frame = adFrame;
[self.adBanner.layer addAnimation:animation forKey:@"frame"];
CGRect buttonViewFrame = CGRectMake(self.ButtonView.frame.origin.x, self.adBanner.frame.origin.y - self.adBanner.frame.size.height, self.ButtonView.frame.size.width, self.ButtonView.frame.size.height);
self.ButtonView.frame = buttonViewFrame;
[self.ButtonView.layer addAnimation:animation forKey:@"frame"];
Run Code Online (Sandbox Code Playgroud)