I have a view like what i have in LaunchScreen.storyboard
and I'm scaling that at run with this code in viewDidLoad
:
UIView.animate(withDuration: 0.4, animations: {
self.aftab_logo.transform = CGAffineTransform(scaleX: 0.6, y: 0.6)
self.aftab_logo.alpha = 0
self.login_content.alpha=1
}, completion: { _ in
self.aftab_logo.removeFromSuperview()
})
When I'm closing app and running again from device this animation doesn't show but when I'm running app from Xcode everything is fine. what is the problem?
This is because your viewDidload
get called before you UI
gets layout. so, if you want any animation related you scaling
any object then you should use viewDidAppear
instead of viewDidload
.
Now if you want animation only one time when user start app not when user come to first screen with navigating back then you should set some flag
and can store it's value somewhere to manage it.
So, take a try in viewDidAppear
instead of viewDidload
!
Update :
I have made one demo something like your setup and it works fine in viewDidload
also. main issue is your duration is very small for viewdidload
to run it.
Once try to change your duration like 2.0
and you will found your animation working perfact!
可能只是加载了先前实现的设备缓存,请尝试从设备中删除该应用程序,然后再次运行。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.