如何在打开页面和此移动后5秒自动显示图像?
我有这段代码,我打开一个页面后5秒钟自动显示图像,但不动就是为什么。
class yourViewController: UIViewController{
@IBOutlet weak var moveobj: UIImageView!
override func viewDidLoad(){
super.viewDidLoad()
moveobj.hidden = true
moveobj.alpha = 0
NSTimer.scheduledTimerWithTimeInterval(5, target: self, selector: #selector(UIViewController.showMyBtn), userInfo: nil, repeats: false)
}
func showMyBtn(){
UIView.animateWithDuration(1, animations: {
self.moveobj.hidden = false
self.moveobj.alpha = 1
})
}
}
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
let orbit = CAKeyframeAnimation(keyPath: "position")
var affineTransform = CGAffineTransformMakeRotation(0.0)
affineTransform = CGAffineTransformRotate(affineTransform, CGFloat(M_PI))
let circlePath = UIBezierPath(arcCenter: CGPoint(x: 198 - (100/2),y: 135 - (100/2)), radius: CGFloat(155), startAngle: CGFloat(255), endAngle:CGFloat(M_PI * 2), clockwise: true)
orbit.path = circlePath.CGPath
orbit.duration = 3
orbit.additive = true
orbit.repeatCount = 0.2
orbit.calculationMode = kCAAnimationPaced
moveobj.layer .addAnimation(orbit, forKey: "orbit")