您的位置:首页 > 移动开发 > IOS开发

IOS动画效果

2015-10-02 16:39 330 查看
在故事版中插入image view绑定一张图片拖入view controller中选择IBOutlet名称为img

先在页面中显示这张图片

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
self.view.addSubview(img)
}


触摸后相应图片效果

override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
//每个效果都需要开始、配置、提交 三步
UIView.beginAnimations(nil, context: nil)
UIView.setAnimationTransition(UIViewAnimationTransition.FlipFromRight, forView: img, cache: true)        //cache是否缓存
UIView.setAnimationDuration(1.0)//时间
UIView.commitAnimations()   //提交
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: