Ser*_*has 4 transformation uiview ios
我学着开发iOS和教育过程的一部分,我已创建自定义的UIView
,它使用drawRect
绘制它的内容(核芯显卡+ UIBezierPath
为主).Everthing按预期工作,视图是动态的,并根据它的宽度/高度呈现它的内容.现在我想添加溶解动画,看起来应该从100%缩放到0%.我写了这段代码来做到这一点:
[UIView animateWithDuration:1 delay:0
options: UIViewAnimationOptionBeginFromCurrentState
animations: ^{
for (CardView *cardView in self.cardsViews) {
cardView.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.01, 0.01);
}} completion:nil];
Run Code Online (Sandbox Code Playgroud)
但是,此代码不会将我的视图从100%缩放到0%.它只是使卡片消失(最多).我已经尝试了很多方法来进行缩放,但到目前为止我所达到的效果只是从0%缩放到100%.我的观点完美,但不能反向缩放...而且,即使我尝试应用非动画变换,它也不会向上/向下缩放,例如:
cardView.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.5, 0.5);
Run Code Online (Sandbox Code Playgroud)
我看到我的视图看起来改变了A BIT,但没有扩展到50%,这是肯定的.当我尝试将完全相同的动画逻辑应用于UILabel时,它完美运行!我错过了开发自定义UIView的哪些方面?缩放视图为何可能出现故障 非常感谢提前!
更新#1此代码使我的视图正好大两倍,然后将其缩放回原始大小:
[UIView animateWithDuration:5 delay:0
options: UIViewAnimationOptionBeginFromCurrentState
animations: ^{
for (CardView *cardView in self.cardsViews) {
cardView.transform = CGAffineTransformMakeScale(0.5, 0.5);
}
} completion:nil];
Run Code Online (Sandbox Code Playgroud)
小智 6
使用CGAffineTransformScale,它很简单,100%到0%:
cardView.view.transform =CGAffineTransformScale(CGAffineTransformIdentity, 1.1, 1.1);
[UIView animateWithDuration:0.3/1.5 animations:^{
cardView.view.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.1, 0.1);
} completion:^(BOOL finished)
{
NSLog(@" Animation complet Block");
}];
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
7160 次 |
最近记录: |